Nettacker icon indicating copy to clipboard operation
Nettacker copied to clipboard

Scan reports in HTML are downloaded in WebUI

Open jess-tech-lab opened this issue 9 months ago • 6 comments

Summary

Currently, when using the WebUI, clicking the link for a completed scan result triggers an automatic download of the HTML file. While having the file locally is useful for archiving, it would improve the user experience if the report rendered directly in the browser.

Steps to Reproduce

In WebUI, click any scan result e.g. https://127.0.0.1:8080/results/get?id=2, the result in HTML is downloaded

Image

I expected scan results in HTML are viewable in the browser window of WebUI

Image

Suggested Fix

The API in nettacker/api/engine.py can change text/plain to text/html and attachment to inline at least for HTML files.

https://github.com/OWASP/Nettacker/blob/ed9c8cad306fdf96b26b54175c30ab218bb84851/nettacker/api/engine.py#L373-L376

https://github.com/OWASP/Nettacker/blob/ed9c8cad306fdf96b26b54175c30ab218bb84851/nettacker/api/engine.py#L393-L394

I am curious if the current "force download" behavior was a deliberate design choice to mitigate security risks, such as preventing potential Cross-Site Scripting (XSS). We might implement a secure rendering method like a sandboxed iframe or strict Content-Security-Policy headers to balance safety with a smoother UI.

I would love to contribute a fix for this if the maintainers agree this is a worthwhile improvement. Please let me know if you would like me to submit a PR.

jess-tech-lab avatar Feb 26 '26 01:02 jess-tech-lab

Hi...!

I would like to work on this issue.

I will investigate the current Content-Disposition handling in the WebUI report endpoint and update it to allow inline HTML rendering while ensuring proper security headers are set to prevent XSS or unsafe content execution.

Please let me know if anyone is already working on it. Thank you!

Sunuz-078 avatar Feb 27 '26 07:02 Sunuz-078

Hey, is this still up for working upon?

denma98 avatar Mar 08 '26 12:03 denma98

Hey, is this still up for working upon?

I've already started working on this. It proved to be a bit of a balancing act between security enhancements and supporting the page's rich JS/CSS, so it's taking a little more time than expected. I should have the PR ready for review by next week!

jess-tech-lab avatar Mar 08 '26 13:03 jess-tech-lab

Hi, I have tried to resolve this issue can you check my PR if it is appropriate

Pbhacks avatar Mar 08 '26 14:03 Pbhacks

Hi, I have tried to resolve this issue can you check my PR if it is appropriate

Hi @Pbhacks, thanks for the PR!

I have reviewed your changes and left a specific suggestion on the PR to further harden the report security.

I’ve suggested adding the sandbox allow-scripts directive to the Content-Security-Policy header. By using allow-scripts without allow-same-origin, we allow the D3.js and renderjson visualizations to function while forcing the report into a unique origin. This ensures that even if malicious data is present in the scan results, it cannot access site-wide cookies or local storage.

I also suggested adding a trailing ; to the font-src attribute to ensure the policy remains valid as we add these new directives. Looking forward to your thoughts on the PR!

jess-tech-lab avatar Mar 08 '26 15:03 jess-tech-lab

Hi @jess-tech-lab , I've checked your suggestions and added them. Thanks a lot for sharing your insights.

Pbhacks avatar Mar 08 '26 15:03 Pbhacks