Skip to content

fix(verification): decode gzip/deflate bodies before the S1 quote check - #169

Merged
BaaRai merged 2 commits into
mainfrom
fix/verification-gzip-body
Nov 10, 2026
Merged

BaaRai merged 2 commits into
mainfrom
fix/verification-gzip-body

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 10, 2026

Copy link
Copy Markdown
Owner

What

Verification S1 now decodes HTTP Content-Encoding on bound response bodies before the quote check. Captured HTML that the proxy stores gzip-compressed was seen as binary and always came back not_assessed, so an exact quote could never verify such a finding.

  • decodeEvidenceBody: gzip or deflate (zlib or raw), one layer only, output capped at 4 MiB decoded. Invalid, truncated or unknown encodings are errors (fail-closed); the raw bytes are never returned in their place.
  • readBoundResponse decodes after the raw read; the stored bytes are unchanged.
  • Empty body with an encoding header returns an empty text body without error, and never matches a quote. A regression test locks this, and mutations of the match, the head fallback and the empty-body guard each turn it red.
  • assessFindingVerification is unchanged: an unreadable body still gives not_assessed.

Decisions to review

  • An empty body sent with Content-Encoding: gzip (HEAD, 304) is not an error. It is safe because an empty text body cannot validate a quote.
  • Brotli and zstd remain not_assessed, with the note evidence body unreadable: unsupported content-encoding.

Verification

  • go build ./..., go vet ./server/: pass. gofmt clean on the CR-stripped content.
  • go test ./server/ -run 'TestDecodeEvidenceBody|TestDecodeBoundResponse': 13 pass, no Postgres needed.
  • Not run here: the TestVerification* tests, which need Postgres. The end-to-end path from a gzip body to verified is therefore not exercised yet. CI runs them against Postgres.
  • Not yet observed: the behaviour on a real stored body. That comes from the end-to-end run on the eval stack, after this PR is merged.

Do not merge before go, shell and web are green on the exact head SHA.

…quote check

Compressed HTML responses are stored as captured, so the S1 receipt check saw them as binary and returned not_assessed. readBoundResponse now undoes the Content-Encoding declared in the snapshot's response head before the text/binary detection and the quote search.

decodeEvidenceBody handles identity and a single layer of gzip or deflate (zlib-wrapped or bare), bounded by verificationReadCap on the decoded side. Any other coding, stacked codings, or a stream that fails to decode is an error, which the caller reports as not_assessed (evidence body unreadable). The stored evidence bytes are unchanged.
…uote

A response captured with Content-Encoding: gzip and no body (HEAD, 304) is
decoded to an empty body without error. Pin that behaviour, and pin that an
empty body, compressed or not, matches no non-empty quote through
readBoundResponse and quoteInBodies, so it can never lead to a verified
finding.
@BaaRai
BaaRai merged commit 59c3702 into main Nov 10, 2026
4 checks passed
@BaaRai BaaRai mentioned this pull request Nov 11, 2026
usinfosec pushed a commit to usinfosec/ARTEX that referenced this pull request Nov 17, 2026
sseUrl() 原先无条件把 SSE 地址拼成 ${hostname}:8787,连生产静态导出
也带这个硬编码。反代到 443 的部署里页面从 https://域名/ 加载,SSE 却被
指向 https://域名:8787/...,而 8787 未对公网开放,导致活动流连不上、反复重连。

改为用 NODE_ENV 区分:生产默认同源(相对路径),仅 next dev 保留 :8787
以绕过 Next.js /api 反代对 SSE 的缓冲。NEXT_PUBLIC_SSE_BASE 覆盖口保留。
验证:NEXT_EXPORT=1 next build 后生产包里 :8787 分支已被 tree-shake。

补充 README 反向代理部署文档(同源说明 + nginx 关缓冲配置)。

Closes BaaRai#169
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