security: harden FRI server and add MATLAB runtime integrity verification (fixes #272)#307
Merged
pradeeban merged 2 commits intoControlCore-Project:devfrom Feb 14, 2026
Conversation
…56 verification (Issue ControlCore-Project#272)
There was a problem hiding this comment.
Pull request overview
This PR hardens the FRI Flask server configuration and improves Docker build security by removing insecure defaults and adding integrity verification for a large external download.
Changes:
- Replaces the hardcoded Flask
secret_keywithFLASK_SECRET_KEYfrom the environment and fails fast when missing. - Ensures the Flask development server is not run with debug enabled (
debug=False) and adds a production WSGI (gunicorn) note. - Adds SHA256 checksum verification for the MATLAB Runtime ZIP download during Docker build.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
fri/server/main.py |
Removes hardcoded secret key, enforces env-based secret key, and explicitly disables Flask debug mode with a production gunicorn note. |
Dockerfile.sh |
Adds a SHA256 checksum check for the MATLAB Runtime download to prevent tampering/MITM issues during builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…h, use ARG for SHA256 override
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.
@pradeeban
Summary
This PR addresses multiple security concerns in the FRI server setup:
1. Hardcoded Secret Key
The Flask secret key was previously hardcoded as
"secret key"in source code, which poses a security risk if deployed publicly. This PR replaces it with an environment-variable-based configuration:FLASK_SECRET_KEYenvironment variableRuntimeErrorif not defined2. Development Server in Production
The Flask app previously ran without explicitly disabling debug mode. This PR:
debug=Falseexplicitly inapp.run()__main__guard3. MATLAB Runtime Integrity Verification
The
Dockerfile.shdownloaded a 2.5GB MATLAB Runtime binary without verifying integrity, introducing MITM risk. This PR:MATLAB_RUNTIME_SHA256environment variable with the expected checksumsha256sum -c -Files Changed
fri/server/main.py— secret key + debug mode fixesDockerfile.sh— SHA256 checksum verificationScope Control
Testing
RuntimeErrorwhenFLASK_SECRET_KEYis not setFLASK_SECRET_KEYdebug=Falseis set and gunicorn comment is present