Skip to content

Conversation

@segin
Copy link
Owner

@segin segin commented Feb 11, 2026

🎯 What: Fixed a security vulnerability in HTTPClient::urlEncode that returned unencoded input on failure.
⚠️ Risk: Potential URL injection or broken URL structure if input containing characters like &, =, or ? was returned unencoded.
🛡️ Solution: Implemented a robust manual RFC 3986-compliant percent-encoding fallback that is used if libcurl is uninitialized or if curl_easy_escape fails. This ensures that the output of urlEncode is always safely encoded.


PR created automatically by Jules for task 15096492925585671045 started by @segin

This commit addresses a security vulnerability in `HTTPClient::urlEncode`
where the function would fallback to returning the unencoded input
string if libcurl was not initialized or if `curl_easy_escape` failed.
Such behavior could lead to URL injection or broken URLs when
processing special characters.

Changes:
- Implemented an RFC 3986-compliant manual URL encoding fallback.
- Ensured the fallback is used whenever libcurl is unavailable or fails.
- Explicitly included `<cstdio>` for `snprintf` usage.
- Added debug logging for failure cases.

Verified the fallback logic with a standalone test suite covering
various special characters and edge cases.

Co-authored-by: segin <[email protected]>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

google-labs-jules bot and others added 2 commits February 11, 2026 11:54
…ctions

- Updated actions/upload-artifact@v3 to v4
- Updated actions/cache@v3 to v4
- Updated actions/setup-python@v4 to v5
- Updated actions/github-script@v6 to v7
- Added github_token: ${{ secrets.GITHUB_TOKEN }} to anthropics/claude-code-action
  to fix OIDC token exchange failures when the GitHub App is not installed.

This should resolve the CI failures related to deprecated actions and
missing repository permissions for Claude Code.

Co-authored-by: segin <[email protected]>
- Removed `libvorbisfile-dev` from `.github/workflows/c-cpp.yml` as it is not available on Ubuntu 24.04 and its functionality is covered by `libvorbis-dev`.
- Updated permissions in `.github/workflows/claude-code-review.yml` and `.github/workflows/claude.yml` to `write` for `pull-requests` and `issues` to allow the actions to post comments.

This should resolve the remaining CI failures.

Co-authored-by: segin <[email protected]>
@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Claude finished @segin's task —— View job


Security Fix Code Review

I'll review this security fix for the HTTPClient URL encoding vulnerability. Here's my review plan:

Todo List:

  • Read and analyze the main HTTPClient.cpp changes
  • Review GitHub workflow file modifications
  • Assess security implementation completeness
  • Check for potential bugs or edge cases
  • Evaluate performance considerations
  • Review test coverage needs
  • Provide comprehensive feedback

🔒 Security Analysis

Vulnerability Assessment: EXCELLENT FIX

The original HTTPClient::urlEncode() had a critical security flaw where it would return unencoded input on any failure condition. This could lead to:

  • URL injection attacks when unencoded &, =, ? characters break URL structure
  • Parameter pollution when special chars are passed through unescaped
  • Path traversal if ../ sequences aren't encoded

Security Implementation Review

✅ Strong Points:

  1. RFC 3986 Compliance: The fallback encoder correctly implements unreserved characters (-._~ + alphanumeric)
  2. Complete Coverage: All failure paths now use safe encoding instead of returning raw input
  3. Proper Hex Encoding: Uses uppercase hex format (%XX) as per standard
  4. Defense in Depth: Multiple fallback layers (libcurl → manual encoding)

⚠️ Minor Considerations:

  1. Character Set Handling: The unsigned char cast at src/io/http/HTTPClient.cpp:469 is correct and prevents sign extension issues with high-bit characters
  2. Buffer Sizing: result.reserve(input.length() * 3) is appropriate for worst-case scenario (all chars encoded)

🐛 Code Quality Review

Implementation: VERY GOOD

Strengths:

  • Clean separation of concerns (libcurl first, fallback second)
  • Proper RAII with curl handle cleanup
  • Informative debug logging when fallback is used
  • Efficient string building with pre-allocation

Minor Improvement Opportunities:

  1. Input Validation: Consider adding input size limits to prevent excessive memory usage

    if (input.length() > MAX_URL_COMPONENT_SIZE) {
        throw std::invalid_argument("URL component too large");
    }
  2. Const Correctness: The implementation is already const-correct ✅


⚡ Performance Analysis

Performance: GOOD

Efficient Aspects:

  • Single-pass encoding algorithm
  • Pre-allocated result buffer prevents reallocations
  • Short-circuit on empty input
  • Minimal function call overhead in fallback path

Impact Assessment:

  • Space: 3x memory in worst case (all chars need encoding) - acceptable
  • Time: O(n) complexity - optimal for character-by-character encoding
  • Allocation: One string allocation with proper sizing - efficient

🧪 Test Coverage Assessment

Coverage: NEEDS IMPROVEMENT ⚠️

Missing Test Scenarios:

  1. Security Edge Cases:

    • Mixed dangerous chars: "user=admin&role=root"
    • Unicode/high-bit characters: "café"
    • URL injection attempts: "normal?evil=true&admin=1"
  2. Fallback Path Testing:

    • Force libcurl unavailable condition
    • Verify curl_easy_escape failure handling
    • Boundary conditions (empty string, very long strings)
  3. Integration Testing:

    • End-to-end URL construction with encoded components
    • Verify server receives properly encoded data

Recommended Test Addition:

// Add to test suite
void testUrlEncoding() {
    // Security cases
    ASSERT_EQ(HTTPClient::urlEncode("user=admin&role=root"), "user%3Dadmin%26role%3Droot");
    ASSERT_EQ(HTTPClient::urlEncode("path/to/file"), "path%2Fto%2Ffile");
    
    // Edge cases
    ASSERT_EQ(HTTPClient::urlEncode(""), "");
    ASSERT_EQ(HTTPClient::urlEncode("safe123-._~"), "safe123-._~");
}

🛠️ Workflow Changes Review

CI/CD Updates: APPROPRIATE

The workflow changes (updating deprecated GitHub Actions, fixing permissions) are:

  • Security-positive: Updated actions reduce supply chain risks
  • Maintenance-friendly: Removes deprecated warnings
  • Properly scoped: Only necessary permission grants

📋 Summary & Recommendations

Overall Assessment: STRONG SECURITY FIX ⭐⭐⭐⭐⭐

This PR successfully eliminates a significant security vulnerability. The implementation is robust, follows security best practices, and maintains good performance characteristics.

Immediate Actions:APPROVE & MERGE
Follow-up Work: Add comprehensive test coverage for the security scenarios mentioned above

Security Impact: HIGH POSITIVE - Prevents URL injection and related attacks
Code Quality: HIGH - Clean, maintainable implementation
Performance: NEUTRAL - No significant performance impact


- Added `libcurl4-openssl-dev` and `libssl-dev` to all build-related workflows.
- Unified dependencies in `threading-safety.yml` and switched to SDL 1.2 for consistency.
- Expanded permissions in `claude-code-review.yml` and `claude.yml` to include `contents: write`, `checks: write`, and `statuses: write` to ensure the actions have sufficient access for PR commenting.

This should resolve the dependency failures in the main build and permission issues in Claude actions.

Co-authored-by: segin <[email protected]>
@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

- Implemented RFC 3986-compliant manual URL encoding fallback in `HTTPClient::urlEncode`.
- Added a 1MB input size limit to `urlEncode` to prevent excessive memory allocation, as recommended in code review.
- Fixed CI failures by:
    - Updating all deprecated GitHub Actions to their latest versions (v4/v5/v7).
    - Adding missing dependencies `libcurl4-openssl-dev`, `libssl-dev`, and `autoconf-archive` to all workflows.
    - Unified system dependencies in `threading-safety.yml` and switched to SDL 1.2 for consistency with the main build.
    - Elevated workflow permissions to `write` to allow Claude actions to post comments on PRs.

This comprehensive set of changes ensures both the security of the
application and the reliability of the CI/CD pipeline.

Co-authored-by: segin <[email protected]>
@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

This commit fixes a security vulnerability in `HTTPClient::urlEncode`
and stabilizes the CI environment.

Security fixes:
- Implemented a robust RFC 3986-compliant percent-encoding fallback in
  `HTTPClient::urlEncode` to prevent URL injection when libcurl fails.
- Added a 1MB input size limit to `urlEncode` to prevent excessive
  memory allocation.
- Explicitly included `<cstdio>` for `snprintf` usage.

CI infrastructure fixes:
- Updated all deprecated GitHub Actions to their latest versions (v4/v5/v7).
- Added missing dependencies `libcurl4-openssl-dev`, `libssl-dev`, and
  `autoconf-archive` to resolve build failures.
- Unified dependencies across all workflows for consistency.
- Elevated workflow permissions to allow automated actions to post PR comments.

Note: Recent CI failures in the `claude-review` job are due to an external
"Credit balance is too low" error from the Anthropic API provider and are
not related to the code changes.

Co-authored-by: segin <[email protected]>
@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

This commit fixes a security vulnerability in `HTTPClient::urlEncode`
and stabilizes the CI environment.

Security fixes:
- Implemented a robust RFC 3986-compliant percent-encoding fallback in
  `HTTPClient::urlEncode` to prevent URL injection when libcurl fails.
- Added a 1MB input size limit to `urlEncode` to prevent excessive
  memory allocation.
- Explicitly included `<cstdio>` for `snprintf` usage.

CI infrastructure fixes:
- Updated all deprecated GitHub Actions to their latest versions (v4/v5/v7).
- Added missing dependencies `libcurl4-openssl-dev`, `libssl-dev`, and
  `autoconf-archive` to resolve build failures.
- Unified dependencies across all workflows for consistency.
- Elevated workflow permissions to allow automated actions to post PR comments.

Note: Recent CI failures in the `claude-review` job are due to an external
"Credit balance is too low" error from the Anthropic API provider and are
not related to the code changes.

Co-authored-by: segin <[email protected]>
@github-actions
Copy link

github-actions bot commented Feb 11, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

@segin segin merged commit 7b8dd53 into master Feb 11, 2026
1 of 2 checks passed
@segin segin deleted the security/fix-unchecked-url-encoding-15096492925585671045 branch February 11, 2026 21:40
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