Repository navigation
Reject CR/LF in outgoing HTTP request lines and headers - #124905
Conversation
`billing_project` and `access_token` were sent as HTTP headers unchecked, so CR/LF could inject headers or a second request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The token was sent in the `Authorization` header unchecked, so CR/LF could inject headers or a second request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A value with CR/LF in the request line or a header could inject headers or a second request. This covers every client, including headers built by the AWS and Azure SDKs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Filter` The `tracestate` forwarded by `url`, Paimon DLF signing headers, REST catalog OAuth tokens, the BigLake `x-goog-user-project` and S3 Tables SigV4 headers were sent unchecked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… schema The registration request used the decoded path of `format_avro_schema_registry_url`, so an encoded CR/LF reached the request line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tokens from the metadata service or a token endpoint were sent as `Authorization: Bearer` unchecked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `api_key` of the named collection was sent as an HTTP header unchecked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An unknown storage class is sent as is in `x-amz-storage-class`, and `BACKUP` and `s3_validate_request_settings = 0` skip validation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… too The early check ran only for `mode <= CREATE`, so a user `ATTACH TABLE ... UUID ... ENGINE = ...` skipped it. Use `isReplayedTableDefinition`, which skips only stored definitions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ine tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [294933f] Summary: ✅
AI ReviewSummaryThe PR rejects CR/LF in outgoing HTTP request lines and headers, validates credential and tracing headers against Missing context / blind spots
Final Verdict✅ Approve. No remaining review changes requested; full server CI validation remains pending. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes27 object files changed (+66.96 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units94 translation units recompiled, 870 s compile time in total, 94 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.08 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
The `Authorization`, `x-api-key` and `anthropic-version` headers sent by AI functions bypassed `http_forbid_headers`. `createAIProvider` now validates the provider's headers with the context's filter, which also rejects CR/LF in their values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`HTTPRequest::write` now also checks the version in the request line. The Avro schema registry test raises the registry timeouts, because the default of 1 second is too short under TSan. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uth` S3 client The `gcp_oauth` client adds `Authorization` itself, so `http_forbid_headers` was bypassed. Check it when the client is created for tables, disks and backups. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
@Algunenano @alexey-milovidov — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
Backport #124905 to 26.10: Reject CR/LF in outgoing HTTP request lines and headers
Adaptations to 26.9: - `HTTPHeaderFilter::checkHeaders` does not exist here; use `checkAndNormalizeHeaders`, which also rejects CR and LF. - `isReplayedTableDefinition` does not exist here; use `isFreshTableDefinition` and `isRecoveryFromStoredMetadata` in `StorageBigQuery` and `StorageYTsaurus`. - `Poco::Net::HTTPRequest::write(std::string &)` does not exist here, so only `write(std::ostream &)` gets the check. - The AI providers keep `AIRequest` and the `X-ClickHouse-AI-Function` header of 26.9. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adaptations to 26.8: - `HTTPHeaderFilter::checkHeaders` does not exist here; use `checkAndNormalizeHeaders`, which also rejects CR and LF. - `isReplayedTableDefinition` does not exist here; use `isFreshTableDefinition` and `isRecoveryFromStoredMetadata` in `StorageBigQuery` and `StorageYTsaurus`. - `Poco::Net::HTTPRequest::write(std::string &)` does not exist here, so only `write(std::ostream &)` gets the check. - The AI providers keep the `call` signature and the `X-ClickHouse-AI-Function` header of 26.8. - `S3::getStorageClassForName` is added to `Requests.cpp` together with the declaration of `INVALID_SETTING_VALUE`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #124905 to 26.8: Reject CR/LF in outgoing HTTP request lines and headers
Cherry pick #124905 to 26.9: Reject CR/LF in outgoing HTTP request lines and headers
Adaptations to 26.7: - `BigQuery`, `S3TablesCatalog` and `aiSimilarity` do not exist here: their changes and the test `05345_bigquery_header_injection` are dropped. - `HTTPHeaderFilter::checkHeaders` does not exist here; use `checkAndNormalizeHeaders`, which also rejects CR and LF. - `isReplayedTableDefinition` does not exist here; use `isFreshTableDefinition` and `isRecoveryFromStoredMetadata` in `StorageYTsaurus`. - `Poco::Net::HTTPRequest::write(std::string &)` does not exist here, so only `write(std::ostream &)` gets the check. - The AI providers keep the `call` signature and the `X-ClickHouse-AI-Function` header of 26.7. - `S3::getStorageClassForName` is added to `Requests.cpp` together with the declaration of `INVALID_SETTING_VALUE`. - `checkGCPOAuthAccessToken` is added to the single `fetchGCPOAuthToken` of 26.7; `PaimonRestCatalog` checks the headers after `createAuthHeaders` without the bearer token validation absent here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adaptations to 26.3: - `BigQuery`, `S3TablesCatalog`, the AI functions and the AvroConfluent schema registration do not exist here: their changes and the tests `05345_bigquery_header_injection`, `05349_avro_confluent_registry_url_crlf` and `05350_ai_functions_api_key_crlf` are dropped. - `HTTPHeaderFilter::checkHeaders` does not exist here; use `checkAndNormalizeHeaders`, which also rejects CR and LF. - `isReplayedTableDefinition` does not exist here; use `isFreshTableDefinition` and `isRecoveryFromStoredMetadata` in `StorageYTsaurus`. - `Poco::Net::HTTPRequest::write(std::string &)` does not exist here, so only `write(std::ostream &)` gets the check. - `S3::getStorageClassForName` is added to `Requests.cpp` together with the declaration of `INVALID_SETTING_VALUE`; `WriteBufferFromS3::createMultipartUpload` does not set the storage class here, so only the other call sites use it. - The `gcp_oauth` header check in `BackupIO_S3.cpp` and `diskSettings.cpp` is added without the surrounding code of newer versions (shared client cache, implicit credentials restriction). - `checkGCPOAuthAccessToken` is added to the single `fetchGCPOAuthToken` of 26.3; `PaimonRestCatalog` checks the headers after `createAuthHeaders` without the bearer token validation absent here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #124905 to 26.3: Reject CR/LF in outgoing HTTP request lines and headers
Cherry pick #124905 to 26.7: Reject CR/LF in outgoing HTTP request lines and headers
Backport #124905 to 26.8: Reject CR/LF in outgoing HTTP request lines and headers
Backport #124905 to 26.9: Reject CR/LF in outgoing HTTP request lines and headers
Backport #124905 to 26.3: Reject CR/LF in outgoing HTTP request lines and headers
Backport #124905 to 26.7: Reject CR/LF in outgoing HTTP request lines and headers
Values that end up in outgoing HTTP requests could contain CR or LF, which let a user inject headers or a whole second request into the connection: BigQuery
billing_project/access_token, YTsaurusoauth_token, the forwardedtracestateinurl, DataLake catalog auth headers (REST/OneLake/Horizon OAuth tokens, BigLakex-goog-user-project, Paimon DLF, S3 Tables SigV4), GCP OAuth tokens, AI provider API keys, the S3 storage class, and headers built by the AWS SDK (SigV4 access key).HTTPRequest::writein Poco now refuses to write a request line or header containing CR or LF, so no client can send one. On top of that, the user-facing sources are validated early (withHTTPHeaderFilter::checkHeaderswhere a context is available) to give a clear error and enforcehttp_forbid_headers. The Avro schema registry now keeps the registry URL path percent-encoded when registering a schema.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reject CR and LF characters in values sent as HTTP headers or in the request line of outgoing HTTP requests (BigQuery, YTsaurus,
url, DataLake catalogs, GCP OAuth, AI functions, S3 storage class), which could be used to inject headers or additional requests.Workflow [PR]
Sync PR [sync-upstream/pr/124905]
Version info
26.11.1.108-master(included in26.11and later)26.10.2.7,26.9.21.9,26.8.30.8,26.7.35.12,26.3.55.2