简体   繁体   English

Fortify 抱怨 Maven 的 pom.xml 外部模式

[英]Fortify complains about Maven's pom.xml external schemas

Based on Fortify (static code analyzer by HP) report, apparently the following lines of pom.xml is vulnerability:根据 Fortify(HP 的静态代码分析器)报告,显然pom.xml的以下行是漏洞:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
...

Because因为

Build Misconfiguration: External Maven Dependency Repository : This maven build script relies on external sources, which could allow an attacker to insert malicious code into the final product or to take control of the build machine.构建错误配置:外部​​ Maven 依赖库:此 maven 构建脚本依赖于外部源,这可能允许攻击者将恶意代码插入最终产品或控制构建机器。

It's somewhat false-positive detection, but according to my company paranoid security policies I cannot suppress this.这有点误报检测,但根据我公司偏执的安全政策,我无法抑制这一点。 So now pom.xml looks like this:所以现在 pom.xml 看起来像这样:

<project>
...

It's still builds/compiles correctly.它仍然可以正确构建/编译。 IDE still recognizes file as a valid Maven Project Object Model file. IDE 仍将文件识别为有效的 Maven 项目 Object ZA559B87068921EEC9CE8408 文件。 Nothing bad happened.没有什么不好的事情发生。

I was wondering is there any possible scenario where this modification might cause some real issues?我想知道是否存在这种修改可能会导致一些实际问题的情况? For example some known tool or parser won't recognize this as a valid Maven's project file.例如,一些已知的工具或解析器不会将其识别为有效的 Maven 项目文件。 Thanks.谢谢。

Just dig into this issue and it turns out Fortify is NOT complains on Maven Schema.只要深入研究这个问题,就会发现 Fortify 不会抱怨 Maven Schema。 It complains you are using external maven repository (central, jboss and so on) and your POM don't have a proper position to mark this issue (ie you don't have any repository defined in POM).它抱怨您正在使用外部 maven 存储库(中央、jboss 等)并且您的 POM 没有适当的位置来标记此问题(即您没有在 POM 中定义任何存储库)。

As fortify said :正如 Fortify 所说

Under Maven, instead of listing explicit URLs from which to retrieve the dependencies, developers specify the dependency names and versions and Maven relies on its underlying configuration to identify the server(s) from which to retrieve the dependencies.在 Maven 下,开发人员指定依赖名称和版本,而不是列出从中检索依赖项的显式 URL,而 Maven 依赖其底层配置来识别从中检索依赖项的服务器。 For commonly used components this saves the developer from having to researching dependency locations.对于常用的组件,这使开发人员不必研究依赖位置。

Two distinct types of attack scenarios affect these systems: An attacker could either compromise the server hosting the dependency or compromise the DNS server the build machine uses to redirect requests for hostname of the server hosting the dependency to a machine controlled by the attacker.两种不同类型的攻击场景会影响这些系统:攻击者可能会破坏托管依赖项的服务器,或者破坏构建机器用来将托管依赖项的服务器的主机名请求重定向到攻击者控制的机器的 DNS 服务器。

You got this vulnerability because you are using external repositories, which give attacker chances to compromise your system by inject tampered dependencies.你得到这个漏洞是因为你使用了外部存储库,这让攻击者有机会通过注入篡改的依赖项来破坏你的系统。 By explicit declare internal repositories, your dependencies are (theoretically) protected by your infrastructures.通过显式声明内部存储库,您的依赖项(理论上)受到您的基础设施的保护。

If you have internal repositories, things like below may be helpful to solve the problem:如果您有内部存储库,以下内容可能有助于解决问题:

<repositories>
  <repository>
    <id>central</id>
    <url>http://172.28.60.140/repository/maven-public</url>
  </repository>
  <repository>
    <id>corp-internal</id>
    <url>http://172.28.60.140/repository/maven-private</url>
  </repository>
</repositories>

Watch out the repository id central , it is necessary since all POM are inherit from super POM.注意存储库 id central ,这是必要的,因为所有 POM 都是从超级 POM 继承的。 By override it, you replace the default central repository with your internal one.通过覆盖它,您可以用内部存储库替换默认的中央存储库。


Remove schemaLocation make Fortify failed to recognize this xml as POM, hence can't determinate the risk.删除schemaLocation使 Fortify 无法将此 xml 识别为 POM,因此无法确定风险。 It doesn't fix anything but hide it.它没有修复任何东西,而是隐藏它。

I do not think they have resolved the issue that was logged, since I do not see any commit.我认为他们没有解决记录的问题,因为我没有看到任何提交。 For me even when I have removed < project > tag, it still complains about the same issue addressed in the question.对我来说,即使我删除了 <project> 标签,它仍然抱怨问题中解决的相同问题。 Note: I am on version 6.21.0005 , using audit workbench , software Fortify Static Code Analyzer.注意:我使用的是 6.21.0005 版本,使用审计工作台,软件 Fortify Static Code Analyzer。

i tried https instead of http and it solves fortify issue.我尝试了 https 而不是 http,它解决了强化问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM