Security: Replace unsafe eval() with safe numeric parsing in core MATLAB library files (Issue #245)#259
Merged
pradeeban merged 8 commits intoControlCore-Project:devfrom Feb 11, 2026
Conversation
There was a problem hiding this comment.
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 <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
|
/gemini review |
Author
|
hey @pradeeban thank you so much for boosting my confidence.... |
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
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