Last active
September 25, 2025 11:47
-
-
Save HouqiyuA/039de857c563aeca0f75bf266a0c9a0d to your computer and use it in GitHub Desktop.
Insecure Default Configuration
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 | |
| def test_error_handling(): | |
| base_url = "http://DEVLOPMENT_HOST:3000/api/v1/user/keys" | |
| # Test cases for error handling analysis | |
| test_cases = [ | |
| ("empty_auth_header", {"Authorization": ""}), | |
| ] | |
| print("=== Testing Error Handling ===") | |
| for name, auth_header in test_cases: | |
| headers = {"Accept": "application/json"} | |
| if auth_header: | |
| headers.update(auth_header) | |
| try: | |
| response = requests.get( | |
| base_url, | |
| headers=headers, | |
| params={"fingerprint": "test", "page": 1, "limit": 1} | |
| ) | |
| print(f"\nTest: {name}") | |
| print(f"Status: {response.status_code}") | |
| print(f"Headers: {response.headers}") | |
| print(f"Body: {response.text}") | |
| # Check for information leakage | |
| if "localhost" in response.text.lower(): | |
| print("!!! Localhost reference detected in error message !!!") | |
| if "swagger" in response.text.lower(): | |
| print("!!! API framework information leaked !!!") | |
| if "token is required" in response.text: | |
| print("!!! Specific auth requirement disclosed !!!") | |
| except Exception as e: | |
| print(f"\nTest: {name} failed with error: {str(e)}") | |
| # Attempt to access the leaked documentation URL | |
| print("\n=== Testing Documentation URL ===") | |
| doc_url = "http://HOST_LEAKED/api/swagger" | |
| try: | |
| response = requests.get(doc_url) | |
| print(f"Documentation URL status: {response.status_code}") | |
| print(f"Content length: {len(response.text)}") | |
| if response.status_code == 200: | |
| print("!!! API documentation accessible !!!") | |
| except Exception as e: | |
| print(f"Failed to access documentation: {str(e)}") | |
| if __name__ == "__main__": | |
| test_error_handling() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment