Skip to content

Commit

Permalink
Introduced protections against deserialization attacks (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeebot[bot] authored and pixeeai committed Dec 1, 2024
1 parent fb68b7e commit 3ece3fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,9 @@
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>io.github.pixee</groupId>
<artifactId>java-security-toolkit</artifactId>
</dependency>
</dependencies>
</project>
2 changes: 2 additions & 0 deletions core/src/main/java/com/alibaba/nacos/core/cluster/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.alibaba.nacos.core.utils.Loggers;
import com.alibaba.nacos.sys.env.EnvUtil;
import com.alibaba.nacos.common.utils.StringUtils;
import io.github.pixee.security.ObjectInputFilters;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -204,6 +205,7 @@ public Member copy() {
// convert the input stream to member object
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
ObjectInputFilters.enableObjectFilterIfUnprotected(ois);
copy = (Member) ois.readObject();
} catch (IOException | ClassNotFoundException e) {
Loggers.CORE.warn("[Member copy] copy failed", e);
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
<spring.version>5.3.39</spring.version>
<spring-security.version>5.8.15</spring-security.version>
<tomcat.version>9.0.93</tomcat.version>
<versions.java-security-toolkit>1.2.0</versions.java-security-toolkit>
</properties>
<!-- == -->
<!-- =========================================================Build plugins================================================ -->
Expand Down Expand Up @@ -1066,6 +1067,11 @@
<artifactId>snakeyaml</artifactId>
<version>${SnakeYaml.version}</version>
</dependency>
<dependency>
<groupId>io.github.pixee</groupId>
<artifactId>java-security-toolkit</artifactId>
<version>${versions.java-security-toolkit}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit 3ece3fb

Please sign in to comment.