Skip to content

fix(security): validate upload_file paths to block secret exfiltration#55

Merged
felixgeelhaar merged 1 commit into
mainfrom
fix/security-followups
Jul 5, 2026
Merged

fix(security): validate upload_file paths to block secret exfiltration#55
felixgeelhaar merged 1 commit into
mainfrom
fix/security-followups

Conversation

@felixgeelhaar

Copy link
Copy Markdown
Collaborator

Problem

UploadFile handed the caller-supplied path straight to DOM.setFileInputFiles with no validation. Because the MCP upload_file tool is driven by an agent that a malicious page can influence, upload_file(input, "~/.ssh/id_rsa") against an attacker-controlled <input type=file> reads and exfiltrates a local secret.

Fix

validateUploadPath now:

  • resolves the path (following symlinks, so a link can't point the upload at a secret),
  • requires an existing regular file (rejects dirs/devices/missing),
  • refuses well-known credential material — a focused denylist of things never legitimately uploaded via a browser form:
    • credential directories: .ssh, .gnupg, .aws, .azure, .kube, .docker, gcloud
    • credential file names: id_rsa/id_dsa/id_ecdsa/id_ed25519, .netrc, .pgpass
    • system secret files: /etc/shadow, /etc/gshadow, /etc/sudoers, /etc/master.passwd

Hermetic unit tests cover the denylist logic and the fs checks (regular file, missing, directory, files under .ssh, files named id_rsa).

Deferred (separate PR)

The other two security-review items — redirect re-validation (a public URL 302-ing to an internal host) and per-origin auth-header scoping (Network.setExtraHTTPHeaders currently leaks the Authorization header to every host) — both require CDP request interception (Fetch domain) and careful coexistence with BlockResources, plus a per-request-overhead trade-off. They deserve their own focused change rather than being rushed in here.

Scout deep-review batch: upload_file finding (MEDIUM).

https://claude.ai/code/session_01QKTcmXFTKoTQr7mB3HCuHZ

UploadFile passed the caller path straight to DOM.setFileInputFiles with no
checks, so an untrusted (page-injected) instruction could upload a local secret
— e.g. upload_file(input, "~/.ssh/id_rsa") against an attacker-controlled file
input reads and exfiltrates the key.

validateUploadPath now resolves the path (following symlinks), requires a
regular existing file, and refuses well-known credential material: credential
directories (.ssh/.gnupg/.aws/.azure/.kube/.docker/gcloud), private-key/.netrc/
.pgpass base names, and system secret files (/etc/shadow etc.). A focused
denylist of things never legitimately uploaded via a browser form.

Note: redirect re-validation and per-origin auth-header scoping (the other two
security-review items) both require CDP request interception and coexistence
with BlockResources — tracked as a separate, design-heavier PR.

Claude-Session: https://claude.ai/code/session_01QKTcmXFTKoTQr7mB3HCuHZ
@felixgeelhaar
felixgeelhaar merged commit 06972c5 into main Jul 5, 2026
7 checks passed
@felixgeelhaar
felixgeelhaar deleted the fix/security-followups branch July 5, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant