Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPFS allows malicious SVG file upload #782

Closed
K0RSHAK opened this issue Sep 30, 2024 · 1 comment
Closed

IPFS allows malicious SVG file upload #782

K0RSHAK opened this issue Sep 30, 2024 · 1 comment
Labels
need/triage Needs initial labeling and prioritization

Comments

@K0RSHAK
Copy link

K0RSHAK commented Sep 30, 2024

Description

During testing [REDACTED] dApp that uses IPFS for storing NFT files it was possible to upload an SVG file with JavaScript inside and perform the XSS attack. Moreover I was able to rewrite uploaded file with the HTML file, including JavaScript code inside.

CVSS: 4.6 Medium AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:N
Env: Ghostnet

Impact

Uploading and hosting an SVG file containing malicious code could lead to various attacks, including:

  • Cross-Site Scripting (XSS): An attacker can embed malicious JavaScript within the SVG file, which could be executed when the file is viewed or rendered in a browser, leading to session hijacking, data theft, or unauthorized actions.
  • Remote Code Execution (RCE): If the SVG contains specially crafted code and the system that processes it is vulnerable, it could lead to remote code execution on the server.
  • Phishing and Social Engineering: Malicious SVGs could be used to spoof content or trick users into taking unintended actions.
  • Attackers can host malicious files on legitimate resources to spread malware, etc.

Evidence

image
Link to check the PoC: https://ipfs.io/ipfs/QmVFs5oNkZVe4EaXkCL8xZn29ziicYnu9KbNdojT8RU59W
Payload:
SVG+XML

<svg xmlns="http://www.w3.org/2000/svg" onload="<WHAT_EVER_FUNCTION_HERE>">
  <text x="10" y="50" font-size="30">XSS PoC</text>
</svg>

HTML

<script>alert('PWND')</script>

Suggestions

  • Sanitize SVG files before upload, remove any additional html attributes, that used for event handling, such as onclick, onload etc. and tags such as <img/> or <script>
  • Adjust Content Security Policy to disallow in-line scripts with script-src 'none' to prevent malicious script execution
  • Validate File Extensions, MIME type and Magic Number - to prevent different upload bypass technics.
@K0RSHAK K0RSHAK added the need/triage Needs initial labeling and prioritization label Sep 30, 2024
@K0RSHAK K0RSHAK closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2024
@K0RSHAK K0RSHAK reopened this Oct 1, 2024
@lidel
Copy link
Member

lidel commented Oct 4, 2024

@K0RSHAK i'm closing this, hopefully the above will point you in the right place to discuss further. in the future or if you still want to report a security issue, please follow https://github.com/ipfs/community/blob/master/SECURITY.md with responsible disclosure sensibility (not posting on public forums).

@lidel lidel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2024
@lidel lidel changed the title IPFS allows malicious file upload IPFS allows malicious SVG file upload Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

2 participants