Reference external data without UAF #1426
-
|
I'm working on adding QuickJS as an embedded scripting engine for our project, allowing users to define custom HTTP filtering logic like We need to read these HTTP requests in JS, something like njs but expressions are provided externally (maybe from a webui) and we don't want to get taken down by bad expressions. We need to pass references to HTTP requests to QuickJS but users can always store them somewhere else (exceptions/promises/...) and cause UAF. We use quickjs-ng through rquickjs and my first approach is to mark pointers as optional ( We're thinking about providing a clean context on every request. Can we clone or reset the context to clean these pointers and avoid recreating prototypes at the same time? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I don't quite follow. Why is that? My first hunch is that, instead of storing pointers, you store an identifier with
Not at the moment, and cloning or resetting probably won't be much faster than simply recreating from scratch. |
Beta Was this translation helpful? Give feedback.
I don't quite follow. Why is that?
My first hunch is that, instead of storing pointers, you store an identifier with
JS_SetOpaque(obj, (void *)(uintptr_t)id), and then use the identifier to look up the corresponding state in a hash map. No match == request expired/completed.Not at the moment, and cloning or resetting probably won't be much faster than simply recreating from scratch.