monperrus / bibtexbrowser

Beautiful publication lists with bibtex and PHP (standalone or in Wordpress)
http://www.monperrus.net/martin/bibtexbrowser/
84 stars 54 forks source link

Fix XSS vulnerability. #134

Closed aklerza closed 6 days ago

aklerza commented 1 week ago

Description In my recent security analysis of bibtexbrowser script, I discovered a significant Stored Cross-Site Scripting (XSS) vulnerability. This flaw exists in the process of listing .bib files in the php script directory. The related function is default_message(), Line 288.

In the Line 299, the PHP script puts file name without proper neutralization or validation. This oversight allows an attacker to craft a malicious file name containing executable JavaScript code, which can then be stored on the server.

Steps to reproduce

  1. Host a local server for the PHP script.
  2. Create a file named <img src=x onerror=alert('xss')>.bib with the help of touch command in the Linux based OSes or use a python script for creating malicious files.
  3. Go to /bibtexbrowser.php?frameset&bib= relative URL with the help of browser.

An alert message will appear on the page – malicious file name executed JavaScript code.

PoC image

image

Fix Implemented

These changes prevent XSS vulnerabilities by ensuring that file names are safe to display and use.

monperrus commented 6 days ago

tahnks @aklerza