Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: encode x-error-msg as JSON - so it does not contain <CR> or <LF>
When the server raises an exception in a HTTP request handler context, more often than not, the exception is sent back to the client in the body. Additionally, the message of the exception (if any), is also copied as is in a x-error-msg HTTP header. That said, HTTP headers must obey strict rules. "\r" and "\n" characters indicate the end of the current HTTP header. When using aiohttp, the library rejects any header that has a "\r" or "\n" in its value: ValueError: Newline or carriage return character detected in HTTP status message or header. This is a potential security issue. As an example, any curtin.util.ProcessExecutionError exception will contain "\n" characters when converted into a string. We now encode the error message as JSON before copying it in the HTTP header. Signed-off-by: Olivier Gayot <[email protected]>
- Loading branch information