Skip to content

reject overlong base64 vlq in source map parser - #503

Open
fr-manvi wants to merge 1 commit into
google:mainfrom
fr-manvi:sourcemap-vlq-shift
Open

reject overlong base64 vlq in source map parser#503
fr-manvi wants to merge 1 commit into
google:mainfrom
fr-manvi:sourcemap-vlq-shift

Conversation

@fr-manvi

Copy link
Copy Markdown

An overlong Base64 VLQ shifts a 32-bit accumulator by 32 or more bits in ReadBase64VLQ:

  • the loop grows shift by 5 for every continuation digit with no cap, unlike the LEB128 readers in webassembly.cc and dwarf/dwarf_util.cc which stop at a max shift
  • a mappings string with 8+ continuation digits reaches shift 35, so digit << shift on the uint32 is an out-of-range left shift (UBSan: shift exponent 35 is too large for 32-bit type)
  • reachable from any source map bloaty loads via --source-map, so a crafted .map triggers it under the undefined-sanitizer fuzz config

Reject once shift hits 32; a valid 32-bit VLQ never gets there, so valid maps are unaffected. Added a regression test under tests/wasm.

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