security: fixes from the upstream hardening review, release 6.9.4 #26

Merged
tim merged 4 commits from security/hardening-review-24 into develop 2026-11-02 19:20:01 +00:00
Owner

Closes #24.

Reviewed the areas upstream 7.0.3 says it hardened (OAuth, RSS fetching, skill bundles) against the Python code. Upstream's Rust diff is not portable, so the review used its release-note checklist: private/loopback blocking and redirect re-checks for RSS, declared-size checks for bundles, size caps / rate limits / strict PKCE and redirect URIs / hashed tokens for OAuth.

Fixed (each test fails on the old code)

  • RSS SSRF: feeds, redirects and article links were fetched with no address check. New rss_worker/safe_fetch.py checks the address at connect time (covers every redirect hop and DNS answers), http(s) only, max 5 redirects. feedparser now gets bytes, so file: URLs and local paths in feeds.yml are no longer readable. RSS_ALLOW_PRIVATE_HOSTS=true opts out; RSS_MAX_FEED_BYTES caps feeds.
  • Skill import zip bomb: ZipFile.read() inflates the whole stream whatever the header declares. A 200 KB bundle declaring 10 bytes allocated 458 MB before the CRC check failed. Entries are now read through open() with a 1 MB cap; the web upload reads at most 20 MB + 1.
  • OAuth redirect URIs: dynamically registered redirect_uri was never validated, and the login handler redirects to it. Now https, loopback http and custom app schemes only; no javascript:/data:/file: etc., fragments or credentials; URI count, length and client name capped.
  • OAuth pending sessions: unauthenticated /authorize grew an in-memory table without bound. Pruned per call, capped at 1000.

Reviewed, left alone (in CHANGELOG)

  • PKCE S256 and exact redirect matching are enforced by the MCP SDK; login is already rate limited; bundle entry names are allowlisted.
  • Tokens are stored plain in Valkey (upstream hashes). Valkey is password protected and oauth:* is not in backups; hashing would sign out every client, so not done.
  • /register has no rate limit and clients have no TTL. Entries are now bounded, flood is still possible slowly. Not fixed here.

Behaviour changes to know about

  • Worker feeds on an internal network need RSS_ALLOW_PRIVATE_HOSTS=true.
  • The worker no longer honours http_proxy.
  • OAuth clients registering http:// redirect URIs on a non-loopback host are refused.

Checks

  • ruff check, ruff format --check, ASCII check, bandit -ll (no findings, no suppressions added).
  • pytest: 2071 passed, 1 skipped (baseline 2008). New: test_safe_fetch.py (real sockets, incl. redirect to loopback), test_skill_transfer_zipbomb.py, test_oauth_hardening.py, upload bound in test_web_skill_transfer.py.
  • Version 6.9.4 + CHANGELOG in this PR; the release PR develop -> main follows.

🤖 Generated with Claude Code

Closes #24. Reviewed the areas upstream 7.0.3 says it hardened (OAuth, RSS fetching, skill bundles) against the Python code. Upstream's Rust diff is not portable, so the review used its release-note checklist: private/loopback blocking and redirect re-checks for RSS, declared-size checks for bundles, size caps / rate limits / strict PKCE and redirect URIs / hashed tokens for OAuth. ## Fixed (each test fails on the old code) - **RSS SSRF**: feeds, redirects and article links were fetched with no address check. New `rss_worker/safe_fetch.py` checks the address at connect time (covers every redirect hop and DNS answers), http(s) only, max 5 redirects. feedparser now gets bytes, so `file:` URLs and local paths in `feeds.yml` are no longer readable. `RSS_ALLOW_PRIVATE_HOSTS=true` opts out; `RSS_MAX_FEED_BYTES` caps feeds. - **Skill import zip bomb**: `ZipFile.read()` inflates the whole stream whatever the header declares. A 200 KB bundle declaring 10 bytes allocated 458 MB before the CRC check failed. Entries are now read through `open()` with a 1 MB cap; the web upload reads at most 20 MB + 1. - **OAuth redirect URIs**: dynamically registered `redirect_uri` was never validated, and the login handler redirects to it. Now https, loopback http and custom app schemes only; no `javascript:`/`data:`/`file:` etc., fragments or credentials; URI count, length and client name capped. - **OAuth pending sessions**: unauthenticated `/authorize` grew an in-memory table without bound. Pruned per call, capped at 1000. ## Reviewed, left alone (in CHANGELOG) - PKCE S256 and exact redirect matching are enforced by the MCP SDK; login is already rate limited; bundle entry names are allowlisted. - Tokens are stored plain in Valkey (upstream hashes). Valkey is password protected and `oauth:*` is not in backups; hashing would sign out every client, so not done. - `/register` has no rate limit and clients have no TTL. Entries are now bounded, flood is still possible slowly. Not fixed here. ## Behaviour changes to know about - Worker feeds on an internal network need `RSS_ALLOW_PRIVATE_HOSTS=true`. - The worker no longer honours `http_proxy`. - OAuth clients registering `http://` redirect URIs on a non-loopback host are refused. ## Checks - `ruff check`, `ruff format --check`, ASCII check, `bandit -ll` (no findings, no suppressions added). - `pytest`: 2071 passed, 1 skipped (baseline 2008). New: `test_safe_fetch.py` (real sockets, incl. redirect to loopback), `test_skill_transfer_zipbomb.py`, `test_oauth_hardening.py`, upload bound in `test_web_skill_transfer.py`. - Version 6.9.4 + CHANGELOG in this PR; the release PR develop -> main follows. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ZipFile.read() inflates the whole stream whatever the header declares,
so the declared-size check did not stop a zip bomb: a 200 KB bundle
declaring 10 bytes allocated over 450 MB before the CRC check failed.
Read entries through open() with a hard cap, and read at most the bundle
cap plus one byte from the web upload.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Feeds, redirects and article links were fetched without checking where
they point, so a hostile feed could reach Valkey or internal services.
Fetch through safe_fetch, which checks the address at connect time (all
redirect hops, no DNS rebinding gap), allows http(s) only and caps
redirects. feedparser now gets bytes instead of a URL, which also closes
file: URLs and local paths. RSS_ALLOW_PRIVATE_HOSTS opts out.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Registered redirect URIs were never checked, and the login handler
redirects the browser to them. Accept https, loopback http and custom app
schemes only, and cap URI count and length and the client name. Prune
expired pending sessions on each /authorize and cap the table.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
release 6.9.4: security fixes from the upstream hardening review
All checks were successful
Lint / Ruff (pull_request) Successful in 9s
Lint / ASCII only (pull_request) Successful in 2s
Security Scans / Bandit, dependency audit, secret scan (pull_request) Successful in 1m38s
Security Scans / Test Coverage (pull_request) Successful in 1m23s
633c013fc7
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tim merged commit f1e747f4f7 into develop 2026-11-02 19:20:01 +00:00
tim deleted branch security/hardening-review-24 2026-11-02 19:20:01 +00:00
Sign in to join this conversation.
No reviewers
No labels
upstream-feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
tim/omnimem!26
No description provided.