GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge changes from forks by chrisvest · Pull Request #17213 · netty/netty

Merge changes from forks #17213

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.

Sign up for GitHub

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

Merged
chrisvest merged 16 commits into netty:4.2 from chrisvest:4.2-sec-merge
Aug 4, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Merge changes from forks #17213

Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
1a896eb
CORS: Don't override vary header if it already exists
normanmaurer Jul 1, 2026
9975553
Encoding-side validation of MQTT fields
chrisvest Jul 1, 2026
c07b97c
Bound SCTP fragmented message buffering
yawkat Jul 3, 2026
6b159a9
Apply suggestion from @yawkat
yawkat Jul 3, 2026
a8f53f2
Correctly handle ClientHello with a handshake header split across TLS…
violetagg Jul 16, 2026
b39650a
Fix NPE risk
chrisvest Jul 23, 2026
5dd41ea
Remove invalid user data from exception messages
chrisvest Jul 23, 2026
4625406
Harden the SOCKS4/5 input validation at encoding time
chrisvest Jul 25, 2026
bb74154
Do not re-aggregate the ClientHello on every received TLS record
violetagg Jul 28, 2026
5f1888e
Validate trust manager configuration
violetagg Aug 3, 2026
9a18e8d
Merge branch '4.2-83wf-socks-nul-byte-sec' into 4.2-sec-merge
chrisvest Aug 4, 2026
2f1ebab
Merge branch 'pr-ghsa-c4c3-7fpv-j4q5-2' into 4.2-sec-merge
chrisvest Aug 4, 2026
74d3007
Merge branch 'pr-ghsa-2qj4-mmr9-4v2f-1' into 4.2-sec-merge
chrisvest Aug 4, 2026
d997aab
Merge branch 'pr-ghsa-8c42-7qj2-3j46-1' into 4.2-sec-merge
chrisvest Aug 4, 2026
93340a5
Merge branch 'hf3j-mqtt-sec' into 4.2-sec-merge
chrisvest Aug 4, 2026
2b45fb0
Merge branch 'pr-ghsa-p85m-gvr3-788c-1' into 4.2-sec-merge
chrisvest Aug 4, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

19 changes: 16 additions & 3 deletions 19 codec-socks/src/main/java/io/netty/handler/codec/socksx/v4/Socks4ClientEncoder.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.EncoderException;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.AsciiString;
import io.netty.util.NetUtil;

/**
Expand All @@ -47,14 +49,25 @@ protected void encode(ChannelHandlerContext ctx, Socks4CommandRequest msg, ByteB
ByteBufUtil.writeShortBE(out, msg.dstPort());
if (NetUtil.isValidIpV4Address(msg.dstAddr())) {
out.writeBytes(NetUtil.createByteArrayFromIpAddressString(msg.dstAddr()));
ByteBufUtil.writeAscii(out, msg.userId());
ByteBufUtil.writeAscii(out, sanitize("userId", msg.userId()));
out.writeByte(0);
} else {
out.writeBytes(IPv4_DOMAIN_MARKER);
ByteBufUtil.writeAscii(out, msg.userId());
ByteBufUtil.writeAscii(out, sanitize("userId", msg.userId()));
out.writeByte(0);
ByteBufUtil.writeAscii(out, msg.dstAddr());
ByteBufUtil.writeAscii(out, sanitize("dstAddr", msg.dstAddr()));
out.writeByte(0);
}
}

private CharSequence sanitize(String fieldName, String strValue) {
for (int i = 0, len = strValue.length(); i < len; i++) {
char c = strValue.charAt(i);
// SOCKS4 uses NUL-bytes as field delimiters.
if (AsciiString.c2b(c) == 0) {
throw new EncoderException("Illegal character in " + fieldName + " field.");
}
}
return strValue;
}
}
25 changes: 20 additions & 5 deletions 25 codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5ClientEncoder.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static void encodeAuthMethodRequest(Socks5InitialRequest msg, ByteBuf ou

final List<Socks5AuthMethod> authMethods = msg.authMethods();
final int numAuthMethods = authMethods.size();
out.writeByte(numAuthMethods);
writeFieldLength(out, numAuthMethods);

if (authMethods instanceof RandomAccess) {
for (int i = 0; i < numAuthMethods; i ++) {
Expand All @@ -97,18 +97,18 @@ private static void encodePasswordAuthRequest(Socks5PasswordAuthRequest msg, Byt
out.writeByte(0x01);

final String username = msg.username();
out.writeByte(username.length());
writeFieldLength(out, username.length());
ByteBufUtil.writeAscii(out, username);

final String password = msg.password();
out.writeByte(password.length());
writeFieldLength(out, password.length());
ByteBufUtil.writeAscii(out, password);
}

private static void encodePrivateAuthRequest(Socks5PrivateAuthRequest msg, ByteBuf out) {
byte[] bytes = msg.privateToken();
out.writeByte(0x01);
out.writeByte(bytes.length);
writeFieldLength(out, bytes.length);
out.writeBytes(bytes);
}

Expand All @@ -119,7 +119,22 @@ private void encodeCommandRequest(Socks5CommandRequest msg, ByteBuf out) throws

final Socks5AddressType dstAddrType = msg.dstAddrType();
out.writeByte(dstAddrType.byteValue());
addressEncoder.encodeAddress(dstAddrType, msg.dstAddr(), out);
String addrValue = msg.dstAddr();
if (addrValue != null && dstAddrType == Socks5AddressType.DOMAIN) {
checkFieldLength(addrValue.length());
}
addressEncoder.encodeAddress(dstAddrType, addrValue, out);
ByteBufUtil.writeShortBE(out, msg.dstPort());
}

private static void writeFieldLength(ByteBuf out, int length) {
checkFieldLength(length);
out.writeByte(length);
}

private static void checkFieldLength(int length) {
if (length > 255 || length < 0) {
throw new EncoderException("Invalid field length value: " + length);
}
}
}
12 changes: 11 additions & 1 deletion 12 codec-socks/src/main/java/io/netty/handler/codec/socksx/v5/Socks5ServerEncoder.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,18 @@ private void encodeCommandResponse(Socks5CommandResponse msg, ByteBuf out) throw

final Socks5AddressType bndAddrType = msg.bndAddrType();
out.writeByte(bndAddrType.byteValue());
addressEncoder.encodeAddress(bndAddrType, msg.bndAddr(), out);
String addrValue = msg.bndAddr();
if (addrValue != null && bndAddrType == Socks5AddressType.DOMAIN) {
checkFieldLength(addrValue.length());
}
addressEncoder.encodeAddress(bndAddrType, addrValue, out);

ByteBufUtil.writeShortBE(out, msg.bndPort());
}

private static void checkFieldLength(int length) {
if (length > 255 || length < 0) {
throw new EncoderException("Invalid field length value: " + length);
}
}
}
84 changes: 84 additions & 0 deletions 84 codec-socks/src/test/java/io/netty/handler/codec/socksx/v4/Socks4ClientEncoderTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2026 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.handler.codec.socksx.v4;

import io.netty.buffer.ByteBuf;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.codec.EncoderException;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

class Socks4ClientEncoderTest {
@Test
public void mustEncodeCommandRequestToIPv4() {
EmbeddedChannel encoder = new EmbeddedChannel(Socks4ClientEncoder.INSTANCE);
DefaultSocks4CommandRequest request = new DefaultSocks4CommandRequest(
Socks4CommandType.CONNECT, "127.0.0.1", 8008, "user");
assertTrue(encoder.writeOutbound(request));
ByteBuf buf = encoder.readOutbound();
assertNotNull(buf);
buf.release();
assertFalse(encoder.finish());
}
@Test
public void mustEncodeCommandRequestToDomain() {
EmbeddedChannel encoder = new EmbeddedChannel(Socks4ClientEncoder.INSTANCE);
DefaultSocks4CommandRequest request = new DefaultSocks4CommandRequest(
Socks4CommandType.CONNECT, "unix://uds.sock", 8008, "user");
assertTrue(encoder.writeOutbound(request));
ByteBuf buf = encoder.readOutbound();
assertNotNull(buf);
buf.release();
assertFalse(encoder.finish());
}

@Test
public void mustRejectNulByteInUserIdWithIPv4Destination() {
EmbeddedChannel encoder = new EmbeddedChannel(Socks4ClientEncoder.INSTANCE);
DefaultSocks4CommandRequest request = new DefaultSocks4CommandRequest(
Socks4CommandType.CONNECT, "127.0.0.1", 8008, "use\0r");
assertThatThrownBy(() -> encoder.writeOutbound(request))
.isInstanceOf(EncoderException.class)
.hasMessageContaining("Illegal character");
assertFalse(encoder.finish());
}

@Test
public void mustRejectNulByteInUserIdWithDomainDestination() {
EmbeddedChannel encoder = new EmbeddedChannel(Socks4ClientEncoder.INSTANCE);
DefaultSocks4CommandRequest request = new DefaultSocks4CommandRequest(
Socks4CommandType.CONNECT, "unix://uds.sock", 8008, "use\0r");
assertThatThrownBy(() -> encoder.writeOutbound(request))
.isInstanceOf(EncoderException.class)
.hasMessageContaining("Illegal character");
assertFalse(encoder.finish());
}

@Test
public void mustRejectNulByteInDstAddr() {
EmbeddedChannel encoder = new EmbeddedChannel(Socks4ClientEncoder.INSTANCE);
DefaultSocks4CommandRequest request = new DefaultSocks4CommandRequest(
Socks4CommandType.CONNECT, "unix://uds\0.sock", 8008, "user");
assertThatThrownBy(() -> encoder.writeOutbound(request))
.isInstanceOf(EncoderException.class)
.hasMessageContaining("Illegal character");
assertFalse(encoder.finish());
}
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.