Skip to content

fix(server): fail closed on unreadable attachment size - #8

Merged
plusky merged 1 commit into
mainfrom
fix/attachment-size-cap
Aug 8, 2026
Merged

fix(server): fail closed on unreadable attachment size#8
plusky merged 1 commit into
mainfrom
fix/attachment-size-cap

Conversation

@plusky

@plusky plusky commented Aug 8, 2026

Copy link
Copy Markdown
Owner

download_attachment read the attachment size with unwrap_or(0), and 0 passes attachment_within_cap for every cap — so metadata with a missing, null, or non-numeric size bypassed global.max_attachment_bytes entirely, and the full body was downloaded and base64-returned with no re-check. The trigger is upstream-controlled, which made the operator's resource bound not a bound.

With a non-zero cap the decision is now fail-closed on unreadable size (I4), and the actually-downloaded byte count is enforced as a backstop so an understated size cannot exceed the cap either. cap == 0 keeps meaning unlimited; the upload path already checked real lengths and is unchanged.

Invariants: I4 (fail-closed on unreadable metadata, applied to the resource bound), I2 (refusal stays within what the guard already decided).

Tests: core unit tests for the Option-aware cap decision plus coverage that unreadable-size metadata refuses before any download; confirmed to fail against the unfixed code.

Process: AI-assisted — implemented and independently adversarially reviewed against docs/DESIGN.md (verdict: approve, with an empirical pre-fix-failure check). Full verification suite green at the commit.

download_attachment treated a missing/non-numeric metadata size as 0,
which always passed the max_attachment_bytes check, so an upstream field
omission voided the operator's resource bound (I4, fail-closed). The cap
gate is now Option-aware in jirakeep-core (unknown size refused when a
non-zero cap is set; cap 0 still unlimited) and the download itself is
streamed with a Content-Length precheck plus a per-chunk byte-count abort.
@plusky plusky added security Guard, key custody, or disclosure surface ai-assisted Found or drafted with AI assistance; claims verified against source, review independently labels Aug 8, 2026
@plusky
plusky enabled auto-merge (rebase) August 8, 2026 19:51
@plusky
plusky merged commit 3b192b5 into main Aug 8, 2026
11 checks passed
@plusky
plusky deleted the fix/attachment-size-cap branch August 8, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Found or drafted with AI assistance; claims verified against source, review independently security Guard, key custody, or disclosure surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant