-
Notifications
You must be signed in to change notification settings - Fork 1
🛡️ Sentinel: [HIGH] Fix XSS risk in folder names #128
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -85,3 +85,33 @@ | |||||||||||
| finally: | ||||||||||||
| main._api_post_form = original_post_form | ||||||||||||
| main.log = original_log | ||||||||||||
|
|
||||||||||||
| def test_validate_folder_data_sanitizes_names(): | ||||||||||||
| """ | ||||||||||||
| Verify that validate_folder_data rejects unsafe folder names (XSS prevention). | ||||||||||||
| """ | ||||||||||||
| # Mock logger to check error messages | ||||||||||||
| mock_log = MagicMock() | ||||||||||||
| original_log = main.log | ||||||||||||
| main.log = mock_log | ||||||||||||
|
|
||||||||||||
| try: | ||||||||||||
| # 1. Valid Folder Name | ||||||||||||
| valid_data = {"group": {"group": "My Safe Folder"}} | ||||||||||||
| assert main.validate_folder_data(valid_data, "https://example.com/valid.json") is True | ||||||||||||
Check noticeCode scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check noticeCode scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||||||||||||
|
|
||||||||||||
| # 2. XSS Payload in Folder Name | ||||||||||||
| xss_data = {"group": {"group": "<script>alert(1)</script>"}} | ||||||||||||
| assert main.validate_folder_data(xss_data, "https://example.com/xss.json") is False | ||||||||||||
Check noticeCode scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check noticeCode scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
|
||||||||||||
| assert mock_log.error.called | ||||||||||||
Check noticeCode scanning / Bandit Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Check noticeCode scanning / Bandit (reported by Codacy) Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Comment on lines
+105
to
+106
|
||||||||||||
| assert main.validate_folder_data(xss_data, "https://example.com/xss.json") is False | |
| assert mock_log.error.called | |
| before_error_calls = mock_log.error.call_count | |
| assert main.validate_folder_data(xss_data, "https://example.com/xss.json") is False | |
| assert mock_log.error.call_count == before_error_calls + 1 |
Check notice
Code scanning / Bandit
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Check warning
Code scanning / Pylintpython3 (reported by Codacy)
Line too long (101/100) Warning test
Check warning
Code scanning / Pylint (reported by Codacy)
Line too long (101/100) Warning test
Check notice
Code scanning / Bandit (reported by Codacy)
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Check notice
Code scanning / Bandit
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
Check notice
Code scanning / Bandit (reported by Codacy)
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Note test
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 dangerous character set for folder names is less restrictive than for rules. The
is_valid_rulefunction blocks<>"'\();{}[]while this function only blocks<>"'``.If the Control D dashboard renders folder names in JavaScript contexts (event handlers, script tags, or embedded in JSON), characters like
();{}[]could still enable injection attacks. For example, a folder name likealert(1)would pass this validation but could be dangerous if rendered asonclick="handleClick('alert(1)')".Consider aligning the character validation with
is_valid_ruleor adding a comment explaining why folder names require less strict validation.