Closed Crispy-fried-chicken closed 9 months ago
Hi @Crispy-fried-chicken!
Thank you for your pull request and welcome to our community.
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed
. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!
Security Vulnerability - Action Required: XXE vulnerability in the newest version of buck
Hi there,
I think the method
com.facebook.buck.features.project.intellij.WorkspaceUpdater.createDocumentBuilder()
may have an XXE vulnerability which is vulnerable in the newest version of buck. It shares similarities to a recent CVE disclosure CVE-2021-4295 in the "onc-healthit/code-validator-api" project.Vulnerability Description: The vulnerability is present in the class
com.facebook.buck.features.project.intellij.WorkspaceUpdater
of methodcreateDocumentBuilder()
, which is responsible for creating a document builder for parsing and processing XML documents. The vulnerable call chain we discover is:Given that the
workspace.xml
which stores the settings and state information of the workspace of an IntelliJ IDEA project is compromised by a hacker (e.g., using<!ENTITY entityname path>
), the victim conducts regular build process which incorporates the execution of methodupdateOrCreateWorkspace()
. As a consequence, the methodcreateDocumentBuilder()
will parse the compromisedworkspace.xml
, resulting in an XML External Entity (XXE) Injection attack.Proof of Concept : To facilitate demonstration, I create a PoC. The implementation steps of PoC are as follows:
Prerequisites: To manually build Buck, download and install the following prerequisites:
clone the buck project and build it: If all pre-preparations have been completed, execute the following command to clone and build the buck:
Move the project which has the
workspace.xml
file that is compromised by a hacker to the buck directory the content of theworkspace.xml
will be like:the codes hacker added are as follows:
In this statement, the
<!DOCTYPE>
statement is used to specify the definition of the entity, where externalEntity is the name of the entity, and the path after the SYSTEM keyword specifies the location of the external file. Then, in the<component>
tag, use&externalEntity;
to refer to the entity, which will be replaced with the content of the external file when parsed.the file
samples.txt
is for demonstration, its content is as follows:Besides, hackers can also construct external entities to obtain users' local files, perform Server-Side Request Forgery(SSRF) attacks, etc.
Use the following command to generate project configuration files for IntelliJ IDEA :
Then the content of
samples.txt
will show in the.idea/workspace.xml
because of the vulnerability I mentioned above. The content of the.idea/workspace.xml
is as follows: