fix(security): denylist plaintext-credential home dotfiles for media delivery - #37086
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Extends the media delivery denylist to block additional plaintext-credential dotfiles (~/.netrc, ~/.git-credentials, ~/.npmrc, ~/.pypirc) from being delivered as native attachments, preventing prompt-injection exfiltration of cleartext tokens/passwords.
Changes:
- Added four credential dotfiles to the
_MEDIA_DELIVERY_DENIED_PREFIXEStuple ingateway/platforms/base.py. - Added a parametrized test verifying these dotfiles are rejected even when the recency-trust window would otherwise allow them.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| gateway/platforms/base.py | Adds .netrc, .git-credentials, .npmrc, .pypirc to the credential denylist. |
| tests/gateway/test_platform_base.py | New parametrized test asserting these dotfiles are denied under fresh-mtime/recency-trust conditions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
934cbf2 to
d18acf9
Compare
…delivery The media-delivery $HOME denylist (_MEDIA_DELIVERY_DENIED_HOME_SUBPATHS) covers cloud-credential directories (.aws, .gcloud, .azure, .kube, .docker) plus .ssh/.gnupg/.config/Library/Keychains, but misses the classic plaintext-credential home dotfiles that hold tokens/passwords in cleartext: ~/.netrc, ~/.git-credentials, ~/.npmrc, ~/.pypirc. These are the single-file twins of the already-blocked ~/.aws/credentials. Add them to the denylist so native media delivery can never attach them, even under recency-trust, hardening defense-in-depth against prompt-injection exfiltrating host secrets as an attachment. The exact-path matcher in _path_under_denied_prefix already handles file entries, so no plumbing change.
d18acf9 to
04c9309
Compare
|
Closing to keep the hardening queue focused — this is a mechanical sibling-widen of an existing denylist/redaction family that hasn't drawn review. Happy to reopen or fold it into a broader hardening pass if that's preferred. |
This is a sibling follow-up to commit 4ec0ade (fix(gateway): denylist config.yaml for media delivery)
4ec0adebe/02d1da49dcovered:~/.hermes/{.env,auth.json,credentials,config.yaml}in the media-delivery denylist, plus the$HOMEcloud-credential directories (.ssh,.aws,.gnupg,.kube,.docker,.azure,.gcloud,Library/Keychains).$HOME—~/.netrc,~/.git-credentials,~/.npmrc,~/.pypirc. Same exfiltration class (~/.aws/credentialsis already blocked;~/.netrcis its single-file twin), reaching a different resource the existing entries miss._MEDIA_DELIVERY_DENIED_HOME_SUBPATHS, so native media delivery can never attach them even under recency-trust.What does this PR do?
Widens the gateway media-delivery credential denylist to cover the common plaintext-credential home dotfiles (
.netrc,.git-credentials,.npmrc,.pypirc). Defense-in-depth against prompt-injection exfiltrating host secrets as a native attachment. The exact-path matcher in_path_under_denied_prefix(_path_is_within(...) or resolved == resolved_denied) already handles single-file denylist entries, so this is a pure data widening with no plumbing change and no behavioral change for legitimate media paths.Related Issue
(none — sibling follow-up to commit 4ec0ade)
Type of Change
Changes Made
gateway/platforms/base.py: add 4 credential dotfiles (.netrc,.git-credentials,.npmrc,.pypirc) to_MEDIA_DELIVERY_DENIED_HOME_SUBPATHS.tests/gateway/test_platform_base.py: parametrized regression proving each dotfile is denied even when freshly produced (recency-trust on).How to Test
uv run --with pytest --with pytest-xdist --with pytest-asyncio python3 -m pytest tests/gateway/test_platform_base.py::TestMediaDeliveryPathValidation -vmain(delivery allowed) and PASS with the production hunk applied.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/gateway/test_platform_base.py::TestMediaDeliveryPathValidation -vand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A$HOMEso it is correct on all platforms — or N/A