Harden CGI status-line parsing in git_http_backend #274

Merged
didericis merged 1 commits from harden-cgi-status-parsing into main 2026-06-25 04:02:21 -04:00
Collaborator

Closes #254.

Summary

_write_cgi_response called int(value.split()[0]) on the Status: header returned by git http-backend with no error handling. An empty or non-numeric value raised ValueError/IndexError that escaped the handler thread.

  • Wrap the parse in try/except (ValueError, IndexError) and fall back to HTTP 500, logging the malformed header value.
  • Add TestMalformedStatusHeader with two cases: empty Status: value and a non-numeric Status: value — both must return 500 without throwing.
Closes #254. ## Summary `_write_cgi_response` called `int(value.split()[0])` on the `Status:` header returned by `git http-backend` with no error handling. An empty or non-numeric value raised `ValueError`/`IndexError` that escaped the handler thread. - Wrap the parse in `try/except (ValueError, IndexError)` and fall back to HTTP 500, logging the malformed header value. - Add `TestMalformedStatusHeader` with two cases: empty `Status:` value and a non-numeric `Status:` value — both must return 500 without throwing.
didericis added 1 commit 2026-06-25 03:47:09 -04:00
fix: guard CGI Status-line parse in _write_cgi_response
test / unit (pull_request) Successful in 32s
test / integration (pull_request) Successful in 16s
lint / lint (push) Successful in 1m47s
test / unit (push) Successful in 32s
test / integration (push) Successful in 16s
Update Quality Badges / update-badges (push) Successful in 1m19s
9a878bd885
An empty or non-numeric Status: header from git http-backend raised
ValueError/IndexError that escaped the handler thread. Wrap the parse
in a try/except and fall back to HTTP 500 instead.

Closes #254
didericis force-pushed harden-cgi-status-parsing from 3a702ccc75 to 9a878bd885 2026-06-25 03:47:09 -04:00 Compare
didericis merged commit 9a878bd885 into main 2026-06-25 04:02:21 -04:00
didericis deleted branch harden-cgi-status-parsing 2026-06-25 04:02:22 -04:00
Sign in to join this conversation.