Skip to content

fix(vision): reject non-image files and enforce website policy (salvage #1940)#3845

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-b8e0ec91
Mar 30, 2026
Merged

fix(vision): reject non-image files and enforce website policy (salvage #1940)#3845
teknium1 merged 1 commit intomainfrom
hermes/hermes-b8e0ec91

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Salvage of #1940 by @Gutslabs. Cherry-picked cleanly with one test fix.

Gaps fixed

Issue Before After
Local non-image files Accepted by extension only — secret.txt renamed to .png would be sent to model Magic-byte validation (PNG/JPEG/GIF/BMP/WebP/SVG headers)
Blocked URLs No check_website_access in vision tool — blocked domains fetched freely Policy check before download
Redirect bypass Allowed URL → blocked redirect went through Re-checks final URL after redirects

Test fix

One test needed _validate_image_url mocked — current main added is_safe_url DNS resolution checks that reject the fake blocked.test domain before the website policy check runs. The original PR predates that addition.

Tests

6967 passed, 11 pre-existing failures, 0 regressions.

#1940)

Three safety gaps in vision_analyze_tool:

1. Local files accepted without checking if they're actually images —
   a renamed text file would get base64-encoded and sent to the model.
   Now validates magic bytes (PNG, JPEG, GIF, BMP, WebP, SVG).

2. No website policy enforcement on image URLs — blocked domains could
   be fetched via the vision tool. Now checks before download.

3. No redirect check — if an allowed URL redirected to a blocked domain,
   the download would proceed. Now re-checks the final URL.

Fixed one test that needed _validate_image_url mocked to bypass DNS
resolution on the fake blocked.test domain (is_safe_url does DNS
checks that were added after the original PR).

Co-authored-by: GutSlabs <GutSlabs@users.noreply.github.com>
@teknium1 teknium1 merged commit 5e67fc8 into main Mar 30, 2026
2 of 3 checks passed
itsXactlY pushed a commit to itsXactlY/hermes-agent that referenced this pull request Mar 30, 2026
NousResearch#1940) (NousResearch#3845)

Three safety gaps in vision_analyze_tool:

1. Local files accepted without checking if they're actually images —
   a renamed text file would get base64-encoded and sent to the model.
   Now validates magic bytes (PNG, JPEG, GIF, BMP, WebP, SVG).

2. No website policy enforcement on image URLs — blocked domains could
   be fetched via the vision tool. Now checks before download.

3. No redirect check — if an allowed URL redirected to a blocked domain,
   the download would proceed. Now re-checks the final URL.

Fixed one test that needed _validate_image_url mocked to bypass DNS
resolution on the fake blocked.test domain (is_safe_url does DNS
checks that were added after the original PR).

Co-authored-by: GutSlabs <GutSlabs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant