-
Notifications
You must be signed in to change notification settings - Fork 33
Security: Replace unsafe eval() with safe numeric parsing in core MATLAB library files (Issue #245) #259
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
Security: Replace unsafe eval() with safe numeric parsing in core MATLAB library files (Issue #245) #259
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses Issue #245 by removing unsafe eval() usage in MATLAB codepaths that parse values from files/strings, replacing it with numeric-only parsing.
Changes:
- Replaced
eval()withsscanf()-based numeric parsing inconcore_read.m,concore_initval.m,concore_default_maxtime.m, andconcore_iport.m. - Added simple input cleanup (
strtrim, removal of[]) before parsing.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| concore_read.m | Replaces eval(ins) with numeric parsing for read payloads. |
| concore_initval.m | Replaces eval(simtime_val) with numeric parsing for init values. |
| concore_default_maxtime.m | Replaces eval(instr) with numeric parsing for maxtime. |
| concore_iport.m | Replaces eval(...) with numeric parsing when extracting port numbers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
/gemini review |
|
hey @pradeeban thank you so much for boosting my confidence.... |
Summary
Fixes #245 - Replaces unsafe
eval()calls with safesscanf()-based numeric parsing in core MATLAB library files.Security Issue
Core MATLAB functions were using
eval()to parse data from files, which could execute arbitrary MATLAB commands if data files were tampered with (e.g., in multi-user labs, shared file systems, or distributed studies).Changes
Replaced
eval()with safe numeric-only parsing in 5 core library files:concore_read.meval(ins)→sscanfparsingconcore_initval.meval(simtime_val)→sscanfparsingconcore_default_maxtime.meval(instr)→sscanfparsingconcore_iport.meval(...)→sscanfparsingconcore_oport.meval(...)→sscanfparsingOut of Scope
Test scripts in
testsou/also containeval()but are excluded per maintainer guidance to keep changes minimal and focused on core library files.Behavior
[1 2 3]→[1 2 3]10→10[system('rm -rf /'), 0, 0]→ Safe failure (no execution)Notes