proto_api_scrubber: return 404 instead of 403 for blocked methods. #42885
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.
Description: Return 404 instead of 403 for blocked methods
Additional Description:
This change updates the
proto_api_scrubberfilter to return404 Not Found(gRPC status5 NOT_FOUND) instead of403 Forbidden(gRPC status7 PERMISSION_DENIED) when a request is rejected due to a method-level blocking rule.Security Motivation:
The primary driver for this change is to prevent potential attackers from enumerating valid endpoints. By returning
403, the server explicitly signals that the method exists but the client is not authorized to access it. Switching to404ensures that clients cannot distinguish between a method that does not exist and a method that they are blocked from accessing. This reduces information leakage regarding the API surface area.Changes:
proto_api_scrubber/filter.ccto reject requests withStatus::NotFoundwhen a method-level match occurs.proto_api_scrubber_test/filter_test.ccunit tests to verify the new status code and local reply string.proto_api_scrubber_test/integration_test.ccto verify the end-to-end behavior returns gRPC status 5.Risk Level:
Low (Behavior change for blocked requests).
Testing:
MethodLevelRestrictionTest).RejectsBlockedMethod).