Skip to content

Reject unreadable request bodies in ICAPFilter - #197

Merged
vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:fix-icap-request-body-read
Nov 24, 2026
Merged

vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:fix-icap-request-body-read

Conversation

@vharseko

@vharseko vharseko commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Return HTTP 400 when ICAPFilter cannot read a request body. This covers errors during the empty-body check and during the read before sending the body to ICAP.

Validation

  • Regression tests cover both read failures, forwarding an empty request, and sending the complete non-empty body to ICAP when the client returns ICAP 204.
  • mvn verify passed on JDK 27 with 1,601 tests. The new test failed as expected when the probe consumed the first byte.

Related pull request

@vharseko vharseko added bug java Pull requests that update Java code labels Nov 23, 2026
@vharseko
vharseko requested a review from maximthomas November 23, 2026 15:31
@vharseko vharseko added security Security fixes and CVE / vulnerability updates tests Adds or updates tests labels Nov 23, 2026
@vharseko
vharseko force-pushed the fix-icap-request-body-read branch from 2763154 to b173664 Compare November 23, 2026 16:39

@maximthomas maximthomas 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.

praise: The new tests exercise read failures during both the empty-body probe and the full read, and verify that an empty body still reaches the next handler.


suggestion (non-blocking): Assert that the ICAP request receives the full readable body.

ICAPFilterTest.java:119

The new probe reads one byte and restores the stream position before getBytes() constructs the ICAP payload. A future regression that loses the probe byte could pass the read-failure and empty-body tests. The current push() and pop() balance was independently verified against Commons HTTP Framework 3.2.2. First-byte probe

Pin: Capture the ICAPRequest sent to a mocked client that returns ICAP 204 and assert that getHttpRequestBody() equals the original non-empty byte array.

vharseko added a commit that referenced this pull request Nov 23, 2026
## Summary

Use the test classpath root in `ScriptTest` so the shared Groovy engine
can find file-backed test scripts when the permissions tests run first.
This addresses the six `Cannot open URL` failures seen in CI for #197.

## Validation

- Reproduced all six failures on `master` with `ScriptTest` first. After
the change, all 40 tests passed in both class orders on JDK 11.
- `mvn -pl openig-core -am verify` passed all 1,072 tests on JDK 11.
@vharseko
vharseko force-pushed the fix-icap-request-body-read branch from b173664 to 577c748 Compare November 24, 2026 08:17
@vharseko

Copy link
Copy Markdown
Member Author

@maximthomas I addressed your review suggestion in 577c748f.

The regression test captures the ICAPRequest sent to a mocked client returning ICAP 204 and compares the request body byte for byte. I verified that the test fails if the probe consumes the first byte. mvn verify passed on JDK 27 with 1,601 tests.

@vharseko
vharseko requested a review from maximthomas November 24, 2026 08:18

@maximthomas maximthomas 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.

praise: The regression test checks the exact bytes sent to ICAP when the client returns 204. ICAPFilterTest.java:139

@vharseko
vharseko merged commit 53f328c into OpenIdentityPlatform:master Nov 24, 2026
15 checks passed
@vharseko
vharseko deleted the fix-icap-request-body-read branch November 24, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug java Pull requests that update Java code security Security fixes and CVE / vulnerability updates tests Adds or updates tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants