-
Notifications
You must be signed in to change notification settings - Fork 0
fix: fixed security vulnerabilities from SAST/DAST scans #1
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,7 +24,8 @@ function checkCurrentTab() { | |||||
|
|
||||||
| urlDiv.textContent = url; | ||||||
|
|
||||||
| fetch('http://127.0.0.1:5000/predict', { | ||||||
| const API_URL = 'https://127.0.0.1:5000/predict'; | ||||||
|
||||||
| const API_URL = 'https://127.0.0.1:5000/predict'; | |
| const API_URL = 'http://127.0.0.1:5000/predict'; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,32 +1,40 @@ | ||||||||||||||||||||
| from flask import Flask, request, jsonify | ||||||||||||||||||||
| from flask import Flask, request, jsonify, make_response | ||||||||||||||||||||
|
||||||||||||||||||||
| from flask import Flask, request, jsonify, make_response | |
| from flask import Flask, request, jsonify |
Copilot
AI
Jan 20, 2026
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.
The CORS configuration allows 'http://localhost:3000' but the API is now expected to be served over HTTPS (as indicated by the extension changes). This creates a mismatch. If the API is served over HTTPS, the CORS origin should also be 'https://localhost:3000' or you should allow both HTTP and HTTPS origins for local development.
| CORS(app, origins=['http://localhost:3000', 'chrome-extension://*']) | |
| CORS(app, origins=['http://localhost:3000', 'https://localhost:3000', 'chrome-extension://*']) |
Copilot
AI
Jan 20, 2026
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.
The Content-Security-Policy header 'default-src self' is too restrictive for an API backend. This CSP is appropriate for web pages but will interfere with API responses. For a JSON API, either remove CSP entirely or use a more appropriate policy that doesn't restrict the API functionality.
| response.headers['Content-Security-Policy'] = "default-src 'self'" |
Copilot
AI
Jan 20, 2026
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.
The '/log' endpoint lacks input validation. The 'url' and 'result' parameters should be validated before being inserted into the database. Consider adding checks for:
- Maximum length limits to prevent excessively large data
- Content validation to ensure 'result' contains expected values (e.g., 'PHISHING' or 'LEGITIMATE')
- Basic format validation for the URL parameter
Copilot
AI
Jan 20, 2026
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.
The parameterized SQL query fix lacks test coverage. Consider adding tests to verify that:
- The endpoint correctly logs valid scan results
- The endpoint handles special characters in URL and result parameters
- SQL injection attempts are properly prevented
Copilot
AI
Jan 20, 2026
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.
The domain validation regex pattern does not properly handle all valid domain formats. It requires at least two parts (e.g., 'example.com') and won't accept single-level domains like 'localhost' or IP addresses. This could break legitimate use cases. Consider whether single-level domains and IP addresses should be supported for the DNS lookup functionality.
Copilot
AI
Jan 20, 2026
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.
The domain validation logic and socket-based DNS lookup lack test coverage. Consider adding tests to verify that:
- Valid domain formats are accepted
- Invalid domain formats (malicious patterns, command injection attempts) are rejected
- The DNS lookup correctly resolves valid domains
- Error handling works for non-existent domains
Copilot
AI
Jan 20, 2026
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.
The validation logic checks 'filename' for '..' and '/' after using 'os.path.basename(filename)' to create 'safe_filename'. Since basename removes directory components, checking the original 'filename' for these patterns after basename has already been applied is redundant. The checks on line 186 should use 'safe_filename' instead of 'filename' for consistency, or better yet, the checks should be performed before calling basename.
| safe_filename = os.path.basename(filename) | |
| if not safe_filename or '..' in filename or filename.startswith('/'): | |
| if not filename or '..' in filename or filename.startswith('/'): | |
| return jsonify({'error': 'Invalid filename'}), 400 | |
| safe_filename = os.path.basename(filename) | |
| if not safe_filename: |
Copilot
AI
Jan 20, 2026
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.
The path traversal protection in the log viewing endpoint lacks test coverage. Consider adding tests to verify that:
- Valid filenames are correctly accessed
- Path traversal attempts (e.g., '../../../etc/passwd') are blocked
- Absolute path attempts are rejected
- Files outside the LOGS_DIR are inaccessible
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.
Using HTTPS with 127.0.0.1 will require a valid SSL/TLS certificate for localhost. Without proper certificate configuration on the Flask server, this will fail with certificate verification errors. Consider either: