forked from nginx/unit
-
Notifications
You must be signed in to change notification settings - Fork 4
fix(security): 1.35.6 hardening stack (14-vector audit remediation) #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
andypost
wants to merge
13
commits into
freeunitorg:pre-1.35.6
Choose a base branch
from
andypost:hardening-1.35.6
base: pre-1.35.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
84c340f
fix(tls): validate cert/key pair and guard wildcard SAN matcher
andypost 499de4b
fix(routing): correct CIDR, regex, and port-range matcher edges
andypost 73e4190
fix(fd): tighten FD/CLOEXEC lifetime across accept/pipe/compression
andypost 0e19453
fix(websocket): tighten frame-bound checks in libunit and protocol
andypost f1ff376
fix(port): bounds-check untrusted shmem offsets in port and libunit
andypost 887e794
fix(sapi): bounds-check app-supplied arguments in language bindings
andypost 03e6b0e
fix(isolation): tighten control-socket, mount, and cgroup boundaries
andypost b59c55b
fix(controller): cap JSON parser limits and harden request state
andypost f259611
fix(http): bound proxy Content-Length and URI/string helpers
andypost 6b8e72c
docs(changes): record 1.35.6 hardening fixes
andypost bb58aed
fix(unit): guard sptr bounds check against tiny buffers
andypost 6dde1b4
fix(isolation): require path separator after rootfs prefix
andypost ca2fa45
fix(fd): fall back to pipe() when pipe2() returns ENOSYS
andypost File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -731,12 +731,23 @@ static void JNICALL | |
| nxt_java_Request_sendWsFrameBuf(JNIEnv *env, jclass cls, | ||
| jlong req_info_ptr, jobject buf, jint pos, jint len, jbyte opCode, jboolean last) | ||
| { | ||
| jlong cap; | ||
| nxt_unit_request_info_t *req; | ||
|
|
||
| req = nxt_jlong2ptr(req_info_ptr); | ||
| uint8_t *b = (*env)->GetDirectBufferAddress(env, buf); | ||
|
|
||
| if (b != NULL) { | ||
| cap = (*env)->GetDirectBufferCapacity(env, buf); | ||
| if (pos < 0 || len < 0 || cap < 0 | ||
| || (jlong) pos > cap | ||
| || (jlong) len > cap - (jlong) pos) | ||
| { | ||
| nxt_java_throw_IllegalStateException(env, | ||
| "sendWsFrame: pos/len out of buffer capacity"); | ||
| return; | ||
| } | ||
|
|
||
| nxt_unit_websocket_send(req, opCode, last, b + pos, len); | ||
|
|
||
| } else { | ||
|
|
@@ -749,9 +760,21 @@ static void JNICALL | |
| nxt_java_Request_sendWsFrameArr(JNIEnv *env, jclass cls, | ||
| jlong req_info_ptr, jarray arr, jint pos, jint len, jbyte opCode, jboolean last) | ||
| { | ||
| jsize cap; | ||
| nxt_unit_request_info_t *req; | ||
|
|
||
| req = nxt_jlong2ptr(req_info_ptr); | ||
|
|
||
| cap = (*env)->GetArrayLength(env, arr); | ||
| if (pos < 0 || len < 0 | ||
| || pos > cap | ||
| || len > cap - pos) | ||
| { | ||
| nxt_java_throw_IllegalStateException(env, | ||
| "sendWsFrame: pos/len out of array length"); | ||
| return; | ||
| } | ||
|
Comment on lines
+768
to
+776
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if (arr == NULL) {
nxt_java_throw_IllegalStateException(env,
"sendWsFrame: array is null");
return;
}
cap = (*env)->GetArrayLength(env, arr);
if (pos < 0 || len < 0
|| pos > cap
|| len > cap - pos)
{
nxt_java_throw_IllegalStateException(env,
"sendWsFrame: pos/len out of array length");
return;
} |
||
|
|
||
| uint8_t *b = (*env)->GetPrimitiveArrayCritical(env, arr, NULL); | ||
|
|
||
| if (b != NULL) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
outarray parameter is not checked forNULLbefore callingGetArrayLength. If a Java caller passesnull, this will cause a JVM crash. A defensiveNULLcheck should be added first.