Repository navigation
fix(cpe): bound CPE candidate generation for pathological package metadata - #5356
Merged
Merged
Conversation
a name with thousands of `-`/`_` separators produced one vendor and product candidate per segment, and the vendor x product cross-product made CPE generation roughly cubic in time and memory (8KB name: ~250s, 4.8GB RSS). `generateSubSelections` now stops after 10 prefixes. The full name is still a candidate, so real package names are unaffected. Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
…duct the prefix cap only covered one way to inflate the vendor x product cross-product in `FromPackageAttributes`. Java groupIDs add a vendor (and, with no artifactID, a product) per dot segment, and .NET executables add one of each per file, so a 1000-segment `Bundle-SymbolicName` still produced ~1M CPEs and several GB. - vendor and product candidates are each capped at 64 (shortest first, so truncation is deterministic) - names, versions, and candidates over 512 bytes are skipped, since every byte is paid once per CPE in key building and regex validation real packages produce around a dozen candidates with names well under 100 bytes, so output for real inputs is unchanged. Also corrects the earlier comment: prefixes only become vendor candidates and the cost was quadratic, not cubic. Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
wagoodman
enabled auto-merge (squash)
September 29, 2026 19:36
willmurphyscode
approved these changes
Sep 29, 2026
spiffcs
added a commit
that referenced
this pull request
Sep 30, 2026
* main: (91 commits) feat: catalog CPAN distributions installed by perl clients (#5131) fix(binary): correct traefik version detection on big-endian arches (#5281) Fix hang when scanning a Java resource adapter (.rar) file (#5348) chore(deps): update SPDX license list (#5315) fix: match opensource.org license URLs across SPDX URL forms (#5361) Speed up unit tests in CI (#5360) Fix missing file hashes when running on windows system (#5341) Stop reading the mount table for every single-file source (#5257) fix: conan expat CPE (#5259) fix(spdx): write a name for the root package when the source has none (#5349) fix(python): link uv.lock dependents to the locked version they name (#5351) fix: suppress misleading upstream CPE for PHP extension binaries (#5102) fix: report scanner errors and raise the line cap in metadata parsers (#5353) Harden cataloger parsers against truncated input (do not panic) (#5355) fix(cpe): bound CPE candidate generation for pathological package metadata (#5356) test(golang): make the UPX fixture exercise loader padding (#5354) fix(golang): account for UPX's loader padding when unpacking Go binaries (#5347) test(snap): bound the kernel changelog bomb fixture by ratio, not a fixed 1MB (#5352) test(debian): bound the bomb fixture by ratio, not a fixed 1MB (#5350) fix(ai): handle malformed GGUF headers without panicking (#5345) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CPE generation in
FromPackageAttributescrosses every vendor candidate with every product candidate. Several inputs could inflate those counts without bound, so hostile package metadata could cost minutes and GBs:-/_separators became one vendor candidate per segment prefix, each O(name length). That's quadratic: an 8KB name took ~250s and 4.8GB.Bundle-SymbolicNameproduced ~1M CPEs and 8.4GB.Executableshave the same shape, one vendor and one product per file.The fix bounds things in two places:
generateSubSelectionsstops after 10 prefixes (the full name is still a candidate).FromPackageAttributesskips names/versions over 512 bytes, drops candidates over 512 bytes, and keeps at most 64 vendor and 64 product candidates (shortest first, so truncation is deterministic).Real packages produce around a dozen candidates, with names well under 100 bytes, so output for real inputs shouldn't change.