Skip to content

Commit 4ff30b6

Browse files
authored
Merge branch '2.x' into 2.x_fix_arm64
2 parents 1119aed + d577cfc commit 4ff30b6

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

changes/en-us/2.x.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Add changes here for all PR submitted to the 2.x branch.
6363
- [[#6264](https://github.com/apache/incubator-seata/pull/6264)] fix jib-maven-plugin build failed
6464
- [[#6246](https://github.com/apache/incubator-seata/pull/6246)] build the frontend at the same time as the maven build
6565
- [[#6265](https://github.com/apache/incubator-seata/pull/6265)] optimization fails to build frontend on arm64
66+
- [[#6267](https://github.com/apache/incubator-seata/pull/6267)] add Server deserialization validation
6667

6768
### security:
6869
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] Upgrade Guava dependencies to fix security vulnerabilities

changes/zh-cn/2.x.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
- [[#6264](https://github.com/apache/incubator-seata/pull/6264)] 修复 jib-maven-plugin 编译失败问题
6262
- [[#6246](https://github.com/apache/incubator-seata/pull/6246)] 在maven打包的同时打包前端资源
6363
- [[#6265](https://github.com/apache/incubator-seata/pull/6265)] 优化在 arm64 上构建前端失败的问题
64+
- [[#6267](https://github.com/apache/incubator-seata/pull/6267)] 增加 Server 反序列化校验
6465

6566
### security:
6667
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞

core/src/main/java/io/seata/core/rpc/netty/v1/ProtocolV1Decoder.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,26 @@
1616
*/
1717
package io.seata.core.rpc.netty.v1;
1818

19+
import java.util.Map;
20+
1921
import io.netty.buffer.ByteBuf;
2022
import io.netty.channel.ChannelHandlerContext;
2123
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
22-
import io.seata.core.exception.DecodeException;
23-
import io.seata.core.serializer.Serializer;
24+
import io.seata.config.Configuration;
25+
import io.seata.config.ConfigurationFactory;
2426
import io.seata.core.compressor.Compressor;
2527
import io.seata.core.compressor.CompressorFactory;
28+
import io.seata.core.constants.ConfigurationKeys;
29+
import io.seata.core.exception.DecodeException;
2630
import io.seata.core.protocol.HeartbeatMessage;
2731
import io.seata.core.protocol.ProtocolConstants;
2832
import io.seata.core.protocol.RpcMessage;
33+
import io.seata.core.serializer.Serializer;
2934
import io.seata.core.serializer.SerializerServiceLoader;
3035
import io.seata.core.serializer.SerializerType;
3136
import org.slf4j.Logger;
3237
import org.slf4j.LoggerFactory;
3338

34-
import java.util.Map;
35-
3639
/**
3740
* <pre>
3841
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
@@ -62,10 +65,14 @@
6265
public class ProtocolV1Decoder extends LengthFieldBasedFrameDecoder {
6366

6467
private static final Logger LOGGER = LoggerFactory.getLogger(ProtocolV1Decoder.class);
68+
private static final Configuration CONFIG = ConfigurationFactory.getInstance();
69+
private SerializerType serializerType;
6570

6671
public ProtocolV1Decoder() {
6772
// default is 8M
6873
this(ProtocolConstants.MAX_FRAME_LENGTH);
74+
String serializerName = CONFIG.getConfig(ConfigurationKeys.SERIALIZE_FOR_RPC, SerializerType.SEATA.name());
75+
this.serializerType = SerializerType.getByName(serializerName);
6976
}
7077

7178
public ProtocolV1Decoder(int maxFrameLength) {
@@ -142,8 +149,13 @@ public Object decodeFrame(ByteBuf frame) {
142149
frame.readBytes(bs);
143150
Compressor compressor = CompressorFactory.getCompressor(compressorType);
144151
bs = compressor.decompress(bs);
145-
Serializer serializer = SerializerServiceLoader.load(SerializerType.getByCode(rpcMessage.getCodec()));
146-
rpcMessage.setBody(serializer.deserialize(bs));
152+
SerializerType protocolType = SerializerType.getByCode(rpcMessage.getCodec());
153+
if (this.serializerType.equals(protocolType)) {
154+
Serializer serializer = SerializerServiceLoader.load(protocolType);
155+
rpcMessage.setBody(serializer.deserialize(bs));
156+
} else {
157+
throw new IllegalArgumentException("SerializerType not match");
158+
}
147159
}
148160
}
149161

0 commit comments

Comments
 (0)