Fossil SCM

checkin/71d1127e0ab718ba694858cb22381bc322f103a587350923eea05f7613a83dce

1 week, 2 days ago by dmestas

Overread in the multipart form parser

get_bounded_content() in src/cgi.c splits a multipart/form-data body into its parts. It moved past the content of each part but took only the boundary line off the length that remained, so every later part was searched with a length larger than what was left. Any POST of that type, to any page and before any login check, could be read past the end of its buffer. The parser also writes a zero byte where it finds the end of a line, so a write past the end looks possible too; that is read from the code, not shown. The code dates from 2007 and is in every release.

The fix takes the content of each part off the remaining length.

Tested with ASan and UBSan on macOS and Linux (x86-64): a request that ASan stopped on before the fix is now read correctly with no report; a well-formed upload gives the same parameters as before; and malformed and unusual bodies give no report. The tests are in a new test/cgi.test, which will come with the test-suite work. Not run on Windows.

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button