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

HTML search: bug with JS-prototype-property query #13096

Open
jayaddison opened this issue Nov 2, 2024 · 0 comments · May be fixed by #13153
Open

HTML search: bug with JS-prototype-property query #13096

jayaddison opened this issue Nov 2, 2024 · 0 comments · May be fixed by #13153

Comments

@jayaddison
Copy link
Contributor

Describe the bug

In multi-page HTML builds of Sphinx projects that have search functionality enabled and use the default searchtools.js implementation, a user search query (either input manually, or as a result of clicking on a hyperlink to the documentation) for the term __proto__ may produce an error in the user's browser.

Although I don't believe that this is realistically exploitable as a security vulnerability in the client-side code deployed in Sphinx HTML projects, it is a query (a form of user-controlled input) that produces an error at runtime.

How to Reproduce

The problem can be replicated in a minimal Sphinx project containing an empty conf.py file and an empty index.rst file.

Assuming that those two files have been placed in a poc directory, run the following command to build the project:

$ sphinx-build -b html poc _build

...and then serve it on a local webserver:

$ python -m http.server -b 127.0.0.1 -d _build

You should subsequently be able to replicate the error by opening the URL: http://127.0.0.1:8000/search.html?q=__proto__

The error that appears in Firefox's JavaScript developer console is:

Uncaught (in promise) TypeError: Node.appendChild: Argument 1 is not an object.

Environment Information

Platform:              linux; (Linux-6.11.4-rt-amd64-x86_64-with-glibc2.40)
Python version:        3.12.7 (main, Oct  3 2024, 15:15:22) [GCC 14.2.0])
Python implementation: CPython
Sphinx version:        8.2.0+/2137d0d2e
Docutils version:      0.21.2
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

N/A

Additional context

I plan to offer a pull request to resolve this problem alongside this bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant