Repository navigation
Fix AppSec redirect analysis for OkHttp 3.4+ and 4.x - #13683
Conversation
- Report redirects followed by RetryAndFollowUpInterceptor (OkHttp 3.4+, 4.x); keep HttpEngine for 3.0-3.3 - Share AppSecInterceptor.onRedirect: only BlockingException reaches the caller - Release the redirect body and connection when the redirect is blocked - Run okhttp-3.0 latestDepForkedTest and add okhttp4Test suites
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
More details
The static reviewer reported no actionable defects in redirect reporting or blocked-redirect cleanup. Human PR discussion provided no additional technical concerns; runtime compatibility remains unverified.
🤖 Bits Code Review · Commit c7998b7
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Build pipeline has failing jobs for cc41078: What to do next?
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Build pipeline has failing jobs for 3374da2: What to do next?
DetailsSince those jobs are not marked as being allowed to fail, the pipeline will most likely fail. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
This PR is rejected because it was updated |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What Does This Do
AppSecRetryAndFollowUpInstrumentation. It applies an exit advice tookhttp3.internal.http.RetryAndFollowUpInterceptor.followUpRequestand reports each redirect followed by OkHttp 3.4+ and 4.x to AppSec as a separate downstream request: the 3xx response, then the follow-up request.followUpRequest(Response)in 3.4,(Response, Route)in 3.10 to 4.0,(Response, Exchange)in 4.12.AppSecHttpEngineInstrumentationfor OkHttp 3.0-3.3. Both advices now delegate toAppSecInterceptor.onRedirect. It returns early when there is no active span or AppSec context. It rethrows aBlockingExceptionand logs any other failure, so a failure in the AppSec hooks no longer reaches the application's HTTP call. The advices have nosuppress, so that blocking still works.AppSecInterceptor.onBlockedRedirectdoes the cleanup OkHttp skips because the exception comes fromfollowUpRequest. It closes the 3xx body. On OkHttp 3.4-3.13 it also releases theStreamAllocationthrough reflection, because OkHttp only releases it for anIOException. Without that, every blocked redirect leaks a pooled connection.latestDepForkedTestopt-out inokhttp-3.0/build.gradle.okhttp4Test/okhttp4ForkedTestsuites against OkHttp 4.12.0. The module muzzle range[3.0,)already instruments 4.x.blockRequestUrlSuffixto theHttpClientTestAppSec callbacks, and a "test appsec client redirect blocking" scenario inOkHttp3Test. The scenario checks that the redirect is reported, that the call fails withBlockingException, and that no connection stays allocated.AppSecRedirectTestunit tests for the helper and the advice.Motivation
latestDepForkedTesthas run since #13218, and "test appsec client redirect analysis" failed against OkHttp 3.14.9: the redirected request was never captured. The cause is thatokhttp3.internal.http.HttpEngine, where #10252 hooked the redirect analysis, only exists in OkHttp 3.0-3.3. From 3.4 on, redirects are followed inRetryAndFollowUpInterceptor. So AppSec did not analyze redirects on OkHttp 3.4+ and 4.x, and nothing failed.Additional Notes
okhttp4Testoverrides thestrictlyOkHttp 3 / okio 1 versions it inherits fromtestwithresolutionStrategy.force.gradle.lockfilewas regenerated. It only adds theokhttp4Test*configurations; the existing configurations do not change.IastOkHttp3InstrumentationTestis excluded on OkHttp 4. That is an existing IAST gap with the KotlinHttpUrl, tracked in APPSEC-72003.BlockingExceptionnever reaches the user callback. This already happens for any blocked downstream request and is tracked in APPSEC-72004.latestDepTestto OkHttp 3.12.12: the blocking scenario passes with the fix and fails on the connection-pool assertion without it.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: APMLP-2194
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.