Security: Hardcoded Flask Secret Key and CORS Origins
Description
The Flask application has security credentials and environment-specific settings hardcoded into the code:
- SECRET_KEY- is hardcoded to
'12345' (trivially guessable)
- CORS origins-are hardcoded to
http://127.0.0.1 or https://osemosys.herokuapp.com/
- Deployment mode-is controlled by a hardcoded
HEROKU_DEPLOY flag (also used in the frontend)
This pattern makes it difficult to securely deploy the application across different environments.
Why This Matters
Critical security risk : A hardcoded SECRET_KEY compromises session security, CSRF tokens, and JWT signatures
Inflexible deployments : Cannot easily move from dev → staging → production without modifying code
Version control leak : Sensitive values are committed to git history
Violates 12-factor app principles : Configuration should come from the environment, not the codebase
Locations
File: API/app.py
Line 45 : SECRET_KEY
Lines 59–64 : CORS configuration
Current Code (Vulnerable)
Line 45 - HARDCODED SECRET:
app.config['SECRET_KEY'] = '12345'
Lines 59–64 - HARDCODED CORS:
if Config.HEROKU_DEPLOY == 1:
CORS(app, origins=['https://osemosys.herokuapp.com/'])
else:
CORS(app, origins=['http://127.0.0.1:3000', 'http://127.0.0.1:8080'])
File 2 : API/Classes/Base/Config.py
Lines : 42–43
Hardcoded flags (should come from environment):
HEROKU_DEPLOY = 0
AWS_SYNC = 0
File 3 : Base.Class.js
Lines : 6–7, 12–19 (Frontend mirrors backend hardcoding)
static HEROKU = 0;
static AWS_SYNC = 0;
if (this.HEROKU == 0) {
apiUrl = "http://127.0.0.1:5002/"; // Hardcoded
} else {
apiUrl = "https://osemosys.herokuapp.com/"; // Hardcoded
}
Expected Behavior
- SECRET_KEY should be loaded from environment variable
- CORS origins should be configurable via environment (comma-separated list)
- Deployment mode should be determined by environment, not code flag
- Code should work identically in dev, staging, and production without modification
Acceptance Criteria
Security: Hardcoded Flask Secret Key and CORS Origins
Description
The Flask application has security credentials and environment-specific settings hardcoded into the code:
'12345'(trivially guessable)http://127.0.0.1orhttps://osemosys.herokuapp.com/HEROKU_DEPLOYflag (also used in the frontend)This pattern makes it difficult to securely deploy the application across different environments.
Why This Matters
Critical security risk : A hardcoded
SECRET_KEYcompromises session security, CSRF tokens, and JWT signaturesInflexible deployments : Cannot easily move from dev → staging → production without modifying code
Version control leak : Sensitive values are committed to git history
Violates 12-factor app principles : Configuration should come from the environment, not the codebase
Locations
File:
API/app.pyLine 45 :
SECRET_KEYLines 59–64 : CORS configuration
Current Code (Vulnerable)
File 2 :
API/Classes/Base/Config.pyLines : 42–43
File 3 : Base.Class.js
Lines : 6–7, 12–19 (Frontend mirrors backend hardcoding)
Expected Behavior
Acceptance Criteria
SECRET_KEYfrom environment variableFLASK_SECRET_KEY(fallback to secure random if missing)CORS_ORIGINSfrom environment variable (e.g.,"http://localhost:3000,https://prod.example.com")ENVIRONMENTfrom environment variable (dev/staging/prod) instead of hardcoded flag