Skip to content

Validate remote file service names before parsing - #3608

Merged
chenBright merged 2 commits into
apache:masterfrom
songgaoye:fix/remote-file-naming-url-bounds
Oct 16, 2026
Merged

chenBright merged 2 commits into
apache:masterfrom
songgaoye:fix/remote-file-naming-url-bounds

Conversation

@songgaoye

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve

Problem Summary:

RemoteFileNamingService::GetServers() skips leading slashes after ://
without checking the bounds of the service-name string. Malformed service
names such as http://, bns://, and http://// can read past the end of
the string before validation.

What is changed and the side effects?

Changed:

Check the string boundary while skipping slashes and reject service names
without a server address.

Add regression coverage for malformed URL-like service names.

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

Testing

cmake --build build --target brpc_naming_service_unittest -j2
./build/test/brpc_naming_service_unittest \
  --gtest_filter=NamingServiceTest.remotefile_invalid_url

@songgaoye
songgaoye force-pushed the fix/remote-file-naming-url-bounds branch from cfe8885 to 3281ea1 Compare October 14, 2026 11:40
@chenBright
chenBright requested a lite review from Copilot October 16, 2026 03:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open finding
What changed in this PR

Fixes an out-of-bounds read in RemoteFileNamingService::GetServers() when parsing malformed URL-like service names by adding bounds checks while skipping slashes and rejecting inputs without a server address.

Changes:

  • Add bounds checking while skipping ://-prefixed slashes and reject empty server address cases.
  • Add a regression test covering malformed service names like http://, bns://, and http:////.
File Description
test/​brpc_naming_service_unittest.cpp Adds a regression test ensuring malformed URL-like service names are rejected.
src/​brpc/​policy/​remote_file_naming_service.cpp Prevents out-of-bounds access and returns an error when no server address exists after ://.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/brpc_naming_service_unittest.cpp Resolved

@wasphin wasphin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chenBright chenBright left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chenBright
chenBright merged commit 36c2d12 into apache:master Oct 16, 2026
27 of 28 checks passed
@songgaoye
songgaoye deleted the fix/remote-file-naming-url-bounds branch October 16, 2026 12:31
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.

4 participants