Security audit 7368610658854629919 - #17
Merged
Merged
Conversation
- Replaced multiple unwraps that could cause panics with proper error mapping or grace handling, including: Zip extraction, Lexer EOF during escapes, XML parser element lookup, Web module server initialization/recv loop. - Added null checks before un-wrapping C strings from FFI pointers in native_runtime APIs (structs, enums, models). - Addressed Unsafe C-String manipulation panics in LLVM backend codegen. - Replaced dangerous raw pointer dereferencing for `rusqlite::Connection` with a thread-local static `HashMap` approach, returning `i64` mapping IDs instead of pointers back to the runtime to avoid "use-after-free" vulnerabilities from untrusted user scripts. - Removed manual extraction-directory bounding check in `untar_archive` which was causing functional extraction regression, as the `tar` library unpack handles slip traversal protections inherently. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com>
- Revert manual directory traversal checks in `untar_archive` which incorrectly broke valid relative extraction paths (tar-rs already handles slip traversal checks internally via `unpack`). - Refactor SQLite connection passing: Replaced highly insecure raw `Box::into_raw`/`Box::from_raw` pointer casts mapping connection handles as script integers, which allowed malicious or buggy scripts to perform arbitrary memory manipulation or use-after-frees. Now safely maintained via a `thread_local` `RefCell<HashMap>` mapped by `AtomicI64` IDs. - Ensure all native API memory allocation functions (`ts_alloc_struct`, `ts_alloc_model`, `ts_alloc_enum`) check for null before converting C pointers back into strings, avoiding possible null dereference panics. - Address unwraps when handling escape characters during compilation to correctly propagate the error on EOF. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com>
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.
Description
Please include a summary of the change, the motivation behind it, and which issue it fixes. Include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of Change
Please delete options that are not relevant:
Checklist