Skip to content

fix(security): guard native image routing with file-safety policy - #58752

Merged
teknium1 merged 1 commit into
mainfrom
salvage/image-routing-read-guard
Jul 5, 2026
Merged

fix(security): guard native image routing with file-safety policy#58752
teknium1 merged 1 commit into
mainfrom
salvage/image-routing-read-guard

Conversation

@teknium1

@teknium1 teknium1 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvage of #58517 by @necoweb3 (cherry-picked onto current main, authorship preserved). Native image routing (agent/image_routing.py::_file_to_data_url) now honors the shared file-safety read guard before embedding local image bytes into outbound model requests — closing the path where a read-denied file (including an image-named symlink pointing at .env/auth.json) could be base64-embedded into a provider request.

Changes

  • agent/image_routing.py: _file_to_data_url() calls raise_if_read_blocked() before read_bytes(). Blocked files are treated like unreadable attachments — logged, returned as skipped, turn continues. Guard failure itself no-ops (best-effort, consistent with the defense-in-depth framing).
  • Regression tests: direct read-denied path, skipped native content parts, and the symlink-disguise case.

Validation

Check Result
tests/agent/test_image_routing.py 97 passed, 0 failed
E2E (real imports, temp HERMES_HOME): .env with real PNG bytes, secret.png symlink → .env, direct auth.json all blocked/skipped
E2E positive control: legit PNG embeds, base64 round-trip byte-identical

11-line guard at the single byte-loading chokepoint used by build_native_content_parts (gateway native multimodal path). Same policy chokepoint as #57698 / #58709.

Closes #58517.

Infographic

image-routing-read-guard

@alt-glitch alt-glitch added type/security Security vulnerability or hardening comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/vision Vision analysis and image generation sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data needs-repro Bug needs reproduction steps P2 Medium — degraded but workaround exists labels Jul 5, 2026
@teknium1
teknium1 merged commit c13281a into main Jul 5, 2026
31 checks passed
@teknium1
teknium1 deleted the salvage/image-routing-read-guard branch July 5, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint needs-repro Bug needs reproduction steps P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data tool/vision Vision analysis and image generation type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants