Repository navigation
Return 400 instead of reporting malformed requests as server errors - #8160
Conversation
Malformed and scanner requests were reported to mothership as server errors; they now get a 4xx response, logged only at debug level.
Also tolerate an already-committed response when rejecting invalid parameters.
|
Since the PR targets Tomcat behavior, I read Tomcat 11.0.26's Request.java to check how it wraps parse errors. Two facts drive the findings:
Finding 1 - [Severity: Medium] — Error classification / information disclosure — api/src/org/labkey/api/action/SpringActionController.java, handleRequest() new MultipartException branch; also ExceptionUtil.getInvalidParameterException()
Finding 2 - [Severity: Low] — Robustness — api/src/org/labkey/api/util/ExceptionUtil.java, getInvalidParameterException()
Finding 3 - [Severity: Low] — Test coverage — ExceptionUtil.TestCase.handleIt()
|
|
I think an integration test that sends malformed URLs through the Tomcat "front door" would be useful here to prove the fixes definitely. I can code something up next to |
labkey-adam
left a comment
There was a problem hiding this comment.
Claude thinks there's one finding that should be addressed. And I think an integration test would be useful. I can address both, if you concur.
|
Corrections to my review above, after re-reading Tomcat 11.0.26's Finding 1's suggestion was wrong. Having a fileupload
Anything else, such as the bare Finding 3 overstated the problem. The Finding 2 stands as written. Fixes for all three are coming to this branch. |
…tion, logging and reporting each appropriately
labkey-adam
left a comment
There was a problem hiding this comment.
@labkey-jeckels my changes are in and all looks good to me. Up to you to review my changes and merge.
…_invalid_request_400s
## Rationale Verify that malformed requests return the expected status codes ## Related Pull Requests - LabKey/platform#8160 --------- Co-authored-by: labkey-jeckels <jeckels@labkey.com>
Rationale
Malformed requests, mostly from vulnerability scanners, are logged as 500s and reported to mothership as server errors. This PR returns a 4xx for them instead, and stops reporting them.
Tomcat 11 throws on every parameter read once a query string or form body fails to parse. Rendering the standard error page reads parameters too, so even a 404 for such a request became a 500.
Triage notes for these mothership reports: https://claude.ai/artifact/CtxKZANKRqfhZxs7PHEqBr
Related Pull Requests
Changes
Tested against a local server with probe-style requests: invalid UTF-8 and empty-name parameters, a forwarded image request, and broken multipart POSTs to actions and WebDAV. All returned 400 with no errors logged, and normal pages were unaffected.
Tasks