Skip to content

[Swift] Verify enums using their serialized raw type - #9240

Open
HappyCode0806 wants to merge 3 commits into
google:masterfrom
HappyCode0806:security/fix-swift-wide-enum-verifier-width
Open

HappyCode0806 wants to merge 3 commits into
google:masterfrom
HappyCode0806:security/fix-swift-wide-enum-verifier-width

Conversation

@HappyCode0806

Copy link
Copy Markdown

Swift can store a no-payload enum in fewer bytes than its declared raw scalar type. FlatBuffers serializes the raw scalar width, so using the Swift enum type for verifier bounds checks can validate fewer bytes than generated accessors read or write.

This change verifies Self.T, the generated enum's serialized raw type, and adds a regression test for a UInt64-backed enum. The test checks that a truncated value is rejected at the 8-byte boundary while a complete value continues to verify.

Security report: Google Issue Tracker 560859506 (restricted).

Testing:

  • Vulnerable-line negative control fails with the expected missing-error assertion.
  • Fixed targeted regression passes 4/4.
  • Full Swift test suite passes: 95 tests in 15 suites.

Command:

DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swift test

@google-cla

google-cla Bot commented Sep 13, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the swift label Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant