Skip to content

Fix memory safety vulnerabilities (OOB Read & Integer Overflow)#86

Open
izumi-hyun wants to merge 1 commit into
google:masterfrom
izumi-hyun:master
Open

Fix memory safety vulnerabilities (OOB Read & Integer Overflow)#86
izumi-hyun wants to merge 1 commit into
google:masterfrom
izumi-hyun:master

Conversation

@izumi-hyun

@izumi-hyun izumi-hyun commented May 24, 2026

Copy link
Copy Markdown

Summary

This Pull Request improves robustness in two areas of robots.cc that were identified during fuzzing and code review.

Changes

1. Boundary validation in ExtractUserAgent

Adds an explicit p < end check while iterating through the string_view.

This ensures parsing remains constrained to the logical bounds of the provided view and avoids processing bytes beyond the intended range.

2. Integer overflow hardening in Matches

Replaces int-based counters derived from path length with size_t.

This removes potential overflow edge cases when handling extremely large inputs and improves consistency with the surrounding container and length types.

Notes

The previously discussed matching-complexity and percent-encoding consistency observations are not included in this PR, as they may require broader design discussion and separate evaluation.

Validation

All existing 21 unit tests in robots_test.cc pass successfully with these changes.

Fixed two memory safety vulnerabilities identified during security research:
1. Out-of-bounds read in ExtractUserAgent (added length bounds checking).
2. Integer overflow in Matches (refactored numpos to size_t).
@google-cla

google-cla Bot commented May 24, 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.

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