Serialize public API with a global lock (GHSA-q2v4-fh98-357r)#248
Closed
manugarg wants to merge 1 commit into
Closed
Serialize public API with a global lock (GHSA-q2v4-fh98-357r)#248manugarg wants to merge 1 commit into
manugarg wants to merge 1 commit into
Conversation
pacparser keeps its QuickJS runtime/context in process-global state with no synchronization, so a thread in pacparser_find_proxy() racing a pacparser_cleanup() on another thread can free the engine mid-use (assert abort, or heap-use-after-free in -DNDEBUG builds). Guard every public entry point with a single recursive lock (pthread mutex on POSIX, CRITICAL_SECTION on Windows). The lock is recursive so the composite entry points keep working; it only serializes calls and does not make pacparser run PAC scripts concurrently. Link against -pthread in the Makefile and the Python extension. Fixes GHSA-q2v4-fh98-357r. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Owner
Author
|
I don't think this is worth doing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
pacparser_*entry point with a single recursive global lock (pthread mutex on POSIX,CRITICAL_SECTIONon Windows) so a thread infind_proxy()can't be racing acleanup()that frees the QuickJS engine out from under it.Test plan
NO_INTERNET=1 make -C src— builds clean, full test suite passes.main: 5/5JS_FreeRuntimeassertion aborts.setuptoolsin this env);setup.pychange is the-pthreadlink arg only.Notes
find_proxy()'s returned pointer (valid until the next call/cleanup) — the lock prevents the concurrent use-after-free during execution, not a caller holding a stale pointer.🤖 Generated with Claude Code