Skip to content

Fix remaining security issues of BbScanner (#14501) - #14502

Merged
msynk merged 2 commits into
developfrom
msynk/14501-bbscanner-remaining-security-issues
Oct 31, 2026
Merged

msynk merged 2 commits into
developfrom
msynk/14501-bbscanner-remaining-security-issues

Conversation

@msynk

@msynk msynk commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

closes #14501

Summary by CodeRabbit

  • Bug Fixes
    • Improved barcode scanning performance on unusually large or patterned images, helping prevent long delays when MaxiCode and QR code patterns cannot be decoded.
    • Strengthened image-region validation to handle large dimensions and pixel data more reliably.

@msynk
msynk requested a review from yasmoradi as a code owner October 31, 2026 18:42
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 84b8de89-ad28-45e2-accd-ed3ec92dc9f3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d9d06971-86b3-49c1-b54a-9889ff1b46f2
Commits

Reviewing files that changed from the base of the PR and between c24601f and 9b9dc4a.

Files selected for processing: 5
  • src/Utilities/BbScanner/Bit.BbScanner/Decoding/MaxiCode/BbMaxiCodeReader.cs
  • src/Utilities/BbScanner/Bit.BbScanner/Decoding/QrCode/BbQrFinderPatternFinder.cs
  • src/Utilities/BbScanner/Bit.BbScanner/Pipeline/BbBarcodeDecoder.cs
  • src/Utilities/BbScanner/Tests/Bit.BbScanner.Tests/MaxiCodeAndMicroQrTests.cs
  • src/Utilities/BbScanner/Tests/Bit.BbScanner.Tests/QrCodeDecoderTests.cs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

MaxiCode bullseye measurements now have distance limits. QR finder cross-check comments and performance tests were updated. PrepareCutOut now checks region bounds and pixel length with arithmetic that avoids the prior integer overflow paths.

Changes

Scanner hardening

Layer / File(s) Summary
Bound MaxiCode bullseye walks
src/Utilities/BbScanner/Bit.BbScanner/Decoding/MaxiCode/BbMaxiCodeReader.cs, src/Utilities/BbScanner/Tests/Bit.BbScanner.Tests/MaxiCodeAndMicroQrTests.cs
Confirm limits directional measurements to twice the row’s inner-run total. Walk stops at that limit and applies run checks. Three tests check that large bullseye-like matrices return null within 10 seconds.
Document and test QR cross-check bounds
src/Utilities/BbScanner/Bit.BbScanner/Decoding/QrCode/BbQrFinderPatternFinder.cs, src/Utilities/BbScanner/Tests/Bit.BbScanner.Tests/QrCodeDecoderTests.cs
Comments describe existing QR cross-check run-length bounds. Performance tests increase the tall matrix size, reduce its time limit, and add a case with long black rows.
Validate cutout bounds and pixel length
src/Utilities/BbScanner/Bit.BbScanner/Pipeline/BbBarcodeDecoder.cs
PrepareCutOut checks region bounds using subtraction and validates pixel length with a 64-bit product.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: yasmoradi

Merge Risk: Minimal · previous review 9b9dc

No merge-blocking issue was identified. The hardening changes appear ready to merge subject to normal build and test checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #14501 requires overflow-safe long arithmetic for both region-bound and pixel-length checks in PrepareCutOut. The pixel-length product now uses long, but the region checks use int subtra… Perform the region-bound comparisons in long arithmetic. Add or update automated tests that use extreme coordinate and dimension values to verify that invalid regions cannot pass the checks.
Docstring Coverage Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: fixing remaining security and performance issues in BbScanner. It is concise and directly related to the MaxiCode, QR, and bounds-checking changes.
Out of Scope Changes check Passed The changed MaxiCode decoder, QR finder comments and tests, PrepareCutOut validation, and performance tests all address the security and regression objectives in issue #14501. No unrelated change is…
Full details: Out of Scope Changes check

Explanation

The changed MaxiCode decoder, QR finder comments and tests, PrepareCutOut validation, and performance tests all address the security and regression objectives in issue #14501. No unrelated change is shown.

Full details: Linked Issues check

Explanation

Issue #14501 requires overflow-safe long arithmetic for both region-bound and pixel-length checks in PrepareCutOut. The pixel-length product now uses long, but the region checks use int subtraction in frameWidth - region.Width and frameHeight - region.Height. The PR bounds MaxiCode walks, adds the requested QR finder comments, and strengthens the QR and MaxiCode timing tests.

Resolution

Perform the region-bound comparisons in long arithmetic. Add or update automated tests that use extreme coordinate and dimension values to verify that invalid regions cannot pass the checks.

Full details: Docstring Coverage

Explanation

Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 5 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each ring with care,
Short walks now end before the edge.
Tall stripes and lattices meet the clock,
Safe bounds keep lengths in their place.
I twitch my nose and cheer the scan!

@msynk
msynk merged commit 8f2aba6 into develop Oct 31, 2026
8 checks passed
@msynk
msynk deleted the msynk/14501-bbscanner-remaining-security-issues branch October 31, 2026 19:39
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.

Remaining security issues in BbScanner

1 participant