Repository navigation
Conversation
pnoltes
left a comment
There was a problem hiding this comment.
Nice robustness changes. I think the rsa dfi mg_read usage needs some improvement.
|
|
||
| /** | ||
| * @brief Remote Service Admin DFI environment property (named "CELIX_RSA_DFI_MAX_REQUEST_SIZE") which specifies | ||
| * the maximum accepted HTTP request body size in bytes. Requests with a larger body are rejected with a |
There was a problem hiding this comment.
Should this be configurable in bytes? I would expect al uses cases want as mac request size at least 1 MB.
I think it would be better to rename this to CELIX_RSA_DFI_MAX_REQUEST_SIZE_IN_MB and set the default to 16.
There was a problem hiding this comment.
Or CELIX_RSA_DFI_MAX_REQUEST_SIZE_IN_KB so that it can be adjusted for resource-constrained environment?
There was a problem hiding this comment.
👍 , IN_KB will also work for me
|
|
||
| if (contentLength < 0 || (uint64_t)contentLength > rsa->maxRequestSize) { | ||
| RSA_LOG_WARNING(rsa, "Rejecting request with invalid or too large body (content length %lld, max %zu)", (long long)contentLength, rsa->maxRequestSize); | ||
| mg_write(conn, request_too_large_response_headers, strlen(request_too_large_response_headers)); |
There was a problem hiding this comment.
| mg_write(conn, request_too_large_response_headers, strlen(request_too_large_response_headers)); | |
| mg_send_http_error(conn, 413, "%s", "Rejecting request with invalid or too large body (content length %lld)", (long long)contentLength); |
I would not respond with the configured max request size.
The same setup can be use for the 500 error.
| RSA_LOG_ERROR(rsa, "Error allocating memory for request body of %zu bytes", (size_t)contentLength); | ||
| mg_write(conn, internal_error_response_headers, strlen(internal_error_response_headers)); | ||
| } else { | ||
| int nrOfBytesRead = mg_read(conn, data, (size_t)contentLength); |
There was a problem hiding this comment.
note there is overlap in the change with: #851
My proposal is to focus on this PR and I will update #851 after this is merged.
the usage of mg_read should be in a while loop, according to the [documentation])https://github.com/civetweb/civetweb/blob/master/docs/api/mg_read.md), mg_read will return a negative value when there is nothing more the read.
Harden the remote service admin request handling against malformed input. This PR fixes a
heap buffer overflow in the RSA DFI HTTP server and in the discovery endpoint descriptor
parser, and adds validation of shared memory message ranges in the RSA SHM v2 server.