出于安全原因升级 Netty 及其组件的正确方法是什么?

hao*_*lee 7 security spring-boot rx-netty

我们的 Spring Boot(云)应用程序使用 rx-netty,其版本为0.4.20. 它将 netty 及其组件设置为 version 4.1.5.Final

目前我们的安全审核系统发现当前的 netty-codec 版本 ( 4.1.52.Final) 存在漏洞,建议我们升级到版本4.1.68+

我尝试将netty-codecpom.xml 锁定为4.1.68.Final,但后来我发现其他 netty 组件如netty-buffernetty-handler仍然停留在4.1.52

我想知道:

  • 我应该将所有 Netty 组件保持在同一版本吗?
  • 升级各个易受攻击的组件的正确方法是什么?

谢谢

更新:

mvn dependency:tree

...
[INFO] +- io.reactivex:rxnetty-contexts:jar:0.4.20:compile
[INFO] +- io.reactivex:rxnetty-servo:jar:0.4.20:compile
[INFO] |  \- com.netflix.servo:servo-core:jar:0.12.21:runtime
[INFO] +- io.reactivex:rxnetty:jar:0.4.20:compile
[INFO] |  +- io.netty:netty-codec-http:jar:4.1.69.Final:runtime
[INFO] |  |  +- io.netty:netty-common:jar:4.1.69.Final:runtime
[INFO] |  |  +- io.netty:netty-buffer:jar:4.1.52.Final:runtime
[INFO] |  |  +- io.netty:netty-transport:jar:4.1.52.Final:runtime
[INFO] |  |  \- io.netty:netty-codec:jar:4.1.52.Final:runtime
[INFO] |  +- io.netty:netty-handler:jar:4.1.69.Final:runtime
[INFO] |  |  \- io.netty:netty-resolver:jar:4.1.52.Final:runtime
[INFO] |  +- io.netty:netty-transport-native-epoll:jar:4.1.69.Final:runtime
[INFO] |  |  \- io.netty:netty-transport-native-unix-common:jar:4.1.52.Final:runtime
...
Run Code Online (Sandbox Code Playgroud)

Dir*_*yne 4

注意:Spring boot版本2.5.5使用netty 4.1.68.Final,所以如果你升级spring-boot-starter-parent到的话应该没问题2.5.5

话虽如此:

如何在 spring-boot 中升级到更高/更低版本的依赖项:

  • 查看配置的属性spring-boot-dependencies
  • 使用所需的版本更改我的 pom.xml 中的该属性

根据您的情况,添加netty.version:4.1.69.Final到您的属性:

    <properties>
        <java.version>11</java.version>
        <netty.version>4.1.69.Final</netty.version>
        
    </properties>
Run Code Online (Sandbox Code Playgroud)

更新:

<netty.version>4.1.69.Final</netty.version>与 一起使用时spring-boot-starter-parent:2.2.10.RELEASE,请参考 Gist netty-upgrade

当你执行时,mvn dependency:tree你可以看到每个 netty 依赖项都升级为4.1.69.Final

输出按“netty”过滤

    Regel 1: [INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) @ netty-upgrade ---
    Regel 2: [INFO] com.example:netty-upgrade:jar:0.0.1-SNAPSHOT
    Regel 25: [INFO] |  +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.2.10.RELEASE:compile
    Regel 26: [INFO] |  |  +- io.projectreactor.netty:reactor-netty:jar:0.9.12.RELEASE:compile
    Regel 26: [INFO] |  |  +- io.projectreactor.netty:reactor-netty:jar:0.9.12.RELEASE:compile
    Regel 27: [INFO] |  |  |  +- io.netty:netty-codec-http2:jar:4.1.69.Final:compile
    Regel 27: [INFO] |  |  |  +- io.netty:netty-codec-http2:jar:4.1.69.Final:compile
    Regel 28: [INFO] |  |  |  +- io.netty:netty-handler-proxy:jar:4.1.69.Final:compile
    Regel 28: [INFO] |  |  |  +- io.netty:netty-handler-proxy:jar:4.1.69.Final:compile
    Regel 29: [INFO] |  |  |  |  \- io.netty:netty-codec-socks:jar:4.1.69.Final:compile
    Regel 29: [INFO] |  |  |  |  \- io.netty:netty-codec-socks:jar:4.1.69.Final:compile
    Regel 30: [INFO] |  |  |  \- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.69.Final:compile
    Regel 30: [INFO] |  |  |  \- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.69.Final:compile
    Regel 42: [INFO] +- io.reactivex:rxnetty:jar:0.5.1:runtime
    Regel 44: [INFO] |  +- io.netty:netty-codec-http:jar:4.1.69.Final:compile
    Regel 44: [INFO] |  +- io.netty:netty-codec-http:jar:4.1.69.Final:compile
    Regel 45: [INFO] |  |  +- io.netty:netty-common:jar:4.1.69.Final:compile
    Regel 45: [INFO] |  |  +- io.netty:netty-common:jar:4.1.69.Final:compile
    Regel 46: [INFO] |  |  +- io.netty:netty-buffer:jar:4.1.69.Final:compile
    Regel 46: [INFO] |  |  +- io.netty:netty-buffer:jar:4.1.69.Final:compile
    Regel 47: [INFO] |  |  +- io.netty:netty-transport:jar:4.1.69.Final:compile
    Regel 47: [INFO] |  |  +- io.netty:netty-transport:jar:4.1.69.Final:compile
    Regel 48: [INFO] |  |  \- io.netty:netty-codec:jar:4.1.69.Final:compile
    Regel 48: [INFO] |  |  \- io.netty:netty-codec:jar:4.1.69.Final:compile
    Regel 49: [INFO] |  +- io.netty:netty-handler:jar:4.1.69.Final:compile
    Regel 49: [INFO] |  +- io.netty:netty-handler:jar:4.1.69.Final:compile
    Regel 50: [INFO] |  |  \- io.netty:netty-resolver:jar:4.1.69.Final:compile
    Regel 50: [INFO] |  |  \- io.netty:netty-resolver:jar:4.1.69.Final:compile
    Regel 51: [INFO] |  +- io.netty:netty-transport-native-epoll:jar:4.1.69.Final:runtime
    Regel 51: [INFO] |  +- io.netty:netty-transport-native-epoll:jar:4.1.69.Final:runtime
    Regel 52: [INFO] |  |  \- io.netty:netty-transport-native-unix-common:jar:4.1.69.Final:compile
    Regel 52: [INFO] |  |  \- io.netty:netty-transport-native-unix-common:jar:4.1.69.Final:compile
Run Code Online (Sandbox Code Playgroud)

因此,如果您仍然引用其他版本,请使用mvn dependency:tree查看该引用的来源。