Skip to content

fix(favicon): read icons through the shared cap and skip non-images - #381

Open
TBX3D wants to merge 3 commits into
vmfunc:mainfrom
TBX3D:lane/favicon-hardening
Open

fix(favicon): read icons through the shared cap and skip non-images#381
TBX3D wants to merge 3 commits into
vmfunc:mainfrom
TBX3D:lane/favicon-hardening

Conversation

@TBX3D

@TBX3D TBX3D commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

three problems in the favicon path, all of them producing a hash that is wrong rather than absent.

scan.Favicon capped icon reads at 1MB while the module matcher path reads through httpx.ReadCappedBody at 5MB, so any icon over 1MB fed two different byte streams into the same shared FaviconHash and gave two different shodan pivots. getFaviconBytes also only rejected non-200s and empty bodies, so a 200 text/html soft-404 got hashed as an icon, which the doc comment claimed was already handled. and favicon-gitlab.yaml hardcodes a hash duplicating fingerprint.faviconTech with nothing binding the two, so the new drift test walks favicon-*.yaml and checks every declared hash against the table.

TBX3D added 3 commits July 30, 2026 00:21
…dentically

scan.Favicon capped icon reads at 1MB while the module matcher path reads via
httpx.ReadCappedBody's 5MB cap, so the two SSOT paths fed different byte
streams into the same shared FaviconHash for any icon over 1MB, producing a
different hash and a wrong -favicon shodan pivot. drop the standalone
faviconBodyReadCap constant and read through httpx.MaxBodySize instead.
getFaviconBytes only rejected a non-200 status or an empty body, so a 200
text/html soft-404 page (common when an app has no real 404 handler) got
hashed as if it were the icon, producing a bogus hash and shodan pivot. the
doc comment claimed soft-404s were already excluded, which was not true since
soft-404s are 200s. now the body must carry an image/* content-type or sniff
as a known icon format (ico, png, gif, jpeg, webp, svg) before it's hashed.
modules/info/favicon-gitlab.yaml hardcodes a hash that duplicates
fingerprint.faviconTech rather than being generated from it, with nothing
binding the two together. add a test that walks modules/**/favicon-*.yaml,
extracts every declared favicon hash and checks it exists in the table (and,
when the module name mentions a tech, that the name agrees with the table).
verified the guard actually fails on both an unknown hash and a mismatched
tech name before confirming the current yaml matches the table with no
existing drift.
@TBX3D
TBX3D requested a review from vmfunc as a code owner July 31, 2026 02:30
@github-actions github-actions Bot added size/l <500 lines changed scan changes to scan engine tests test changes labels Jul 31, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 68.42105% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@a38ba0a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/scan/favicon.go 68.42% 4 Missing and 2 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #381   +/-   ##
=======================================
  Coverage        ?   64.90%           
=======================================
  Files           ?       88           
  Lines           ?     7875           
  Branches        ?        0           
=======================================
  Hits            ?     5111           
  Misses          ?     2371           
  Partials        ?      393           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

pr summary

3 files changed (+255 -9)

category files
go source 3
tests 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scan changes to scan engine size/l <500 lines changed tests test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants