Skip to content

Log oversized compressed payloads before rejection - #1682

Open
qtjg wants to merge 3 commits into
permissionlesstech:mainfrom
qtjg:contrib/log-oversized-compressed-payload
Open

Log oversized compressed payloads before rejection#1682
qtjg wants to merge 3 commits into
permissionlesstech:mainfrom
qtjg:contrib/log-oversized-compressed-payload

Conversation

@qtjg

@qtjg qtjg commented Aug 18, 2026

Copy link
Copy Markdown

Fixes #1628.

Summary

When a compressed packet declares an expanded size above FileTransferLimits.maxFramedFileBytes, the decoder currently rejects it without logging the reason. This makes oversized compressed payloads difficult to diagnose, particularly when platform-specific limits differ.

This change logs the declared expanded size and configured ceiling at the existing security warning level before rejecting the packet. Acceptance behavior is unchanged.

Tests

Added a v2 regression test that constructs a valid compressed frame whose declared expanded size exceeds the configured limit and verifies that BinaryProtocol.decode rejects it before attempting decompression.

The local source and test files pass deterministic source checks and git diff --check. The full Swift/Xcode suite could not be run in this Linux environment because swift and xcodebuild are unavailable.

qtjg added 3 commits August 19, 2026 02:21
Fixes permissionlesstech#1628.

When a compressed packet declares an expanded size above FileTransferLimits.maxFramedFileBytes, the decoder rejects it silently. This is especially difficult to diagnose when Android permits a larger expanded payload than iOS.

Log the declared size and configured ceiling at the existing security warning level before returning nil. Packet acceptance behavior is unchanged. Add a v2 regression test that exercises the expanded-size guard without attempting decompression.
Restore the verified local BinaryProtocol.swift contents after correcting the UInt16 encoder line. The oversized compressed-payload logging fix remains unchanged.
Add regression coverage for issue permissionlesstech#1628 by constructing a valid v2 compressed frame whose declared expanded size exceeds FileTransferLimits.maxFramedFileBytes and asserting that BinaryProtocol.decode rejects it.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e90fd3869f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +371 to +374
SecureLogger.warning(
"🚫 Compressed payload expanded size exceeds limit: \(originalSize) bytes > \(FileTransferLimits.maxFramedFileBytes) bytes",
category: .security
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid logging each oversized frame twice

When an oversized compressed frame is padded, decode(_:) first calls decodeCore on the padded data and then retries after MessagePadding.unpad; both attempts reach this warning before returning nil, so one received frame emits two identical security warnings and inflates any diagnostic count. Log the rejection only once across the two decode attempts, or propagate the rejection reason to the outer decoder.

Useful? React with 👍 / 👎.

@Chessing234 Chessing234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same BinaryProtocol.swift guard as #1623. please close this as a duplicate — the new test would already pass on main (decode already returns nil) and never asserts the log.

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.

Log silent rejection of oversized compressed payloads instead of dropping with no trace

2 participants