FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

security: mitigate cross-origin credential leaks, prevent CRLF header injection, and disable XML DTD processing by insaf021 · Pull Request #2170 · googleapis/google-http-java-client · GitHub

security: mitigate cross-origin credential leaks, prevent CRLF header injection, and disable XML DTD processing - #2170

Closed
insaf021 wants to merge 2 commits into
googleapis:mainfrom
insaf021:security/harden-http-security-credential-crlf-xxe
Closed

security: mitigate cross-origin credential leaks, prevent CRLF header injection, and disable XML DTD processing#2170
insaf021 wants to merge 2 commits into
googleapis:mainfrom
insaf021:security/harden-http-security-credential-crlf-xxe

Conversation

insaf021 commented Jul 4, 2026

Copy link
Copy Markdown

This PR implements security hardening improvements in the google-http-java-client library to strengthen credential handling across redirects, improve HTTP header validation, and harden XML parsing.

When handling redirects, the original request origin is recorded and compared against the redirected request. If a redirect targets a different origin (scheme, host, or port), sensitive headers such as Authorization and Cookie are removed after execution interceptors run, preventing credentials from being forwarded to cross-origin destinations while preserving existing behavior for same-origin redirects. Unit tests have been added to verify both same-origin and cross-origin redirect behavior.

This PR also adds validation in HttpHeaders#addHeader to reject header names and serialized header values containing carriage return (\r) or line feed (\n) characters by throwing an IllegalArgumentException. Corresponding tests verify that invalid headers are rejected while valid headers continue to serialize correctly.

Additionally, Xml#createParser() now disables DTD processing using XmlPullParser.FEATURE_PROCESS_DOCDECL where supported by the parser implementation, with a graceful fallback for implementations that do not support the feature. Tests have been added to verify that XML documents containing DTD declarations do not process external entities while maintaining normal XML parsing behavior.

The implementation has been validated by running the relevant unit tests. HttpRequestTest, HttpHeadersTest, and XmlTest all pass successfully, with no test failures or errors.

insaf021 requested a review from a team as a code owner July 4, 2026 05:38
product-auto-label Bot added the size: l Pull request size is large. label Jul 4, 2026

elharo commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

This sounds like multiple separate issues. I'm no longer at Google so I don;t know how likely external contributions are to be considered but in general:

  1. File individual issues for each item.
  2. Break the PR up into multiple PRs, each addressing one thing.

Grab bag PRs tend not to go anywhere.

Copy link
Copy Markdown
Author

Splitting this into focused, single-purpose PRs per your feedback:

Each has its own issue and isolated diff. Closing this one in favor of those four.

insaf021 closed this Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL