From 78a2c1ba8171c3e457d85314d984752360ea0126 Mon Sep 17 00:00:00 2001 From: pravinkumar-exe <52107447+pravinkumar-exe@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:35:08 +0530 Subject: [PATCH 1/3] Add placeholder for account deletion vulnerability (Issue #58) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces a minimal placeholder file corresponding to Issue #58, where an authenticated user can delete another user’s account using the /api/users/{user_id} endpoint. Signed-off-by: pravinkumar-exe <52107447+pravinkumar-exe@users.noreply.github.com> --- reports/account-deletion-idor-placeholder.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 reports/account-deletion-idor-placeholder.md diff --git a/reports/account-deletion-idor-placeholder.md b/reports/account-deletion-idor-placeholder.md new file mode 100644 index 00000000..8b9fd9ea --- /dev/null +++ b/reports/account-deletion-idor-placeholder.md @@ -0,0 +1,6 @@ +This pull request serves as a placeholder for the account deletion vulnerability reported in Issue #58, where any authenticated user can delete another user’s account by modifying the user ID in the /api/users/{user_id} endpoint. + +This commit adds a minimal placeholder to fulfill the bug submission requirements. + +Awaiting further instructions from the maintainers. Thank you. + From 5120c44c8caf2e8980fcfee51ed8aaea2450ae3b Mon Sep 17 00:00:00 2001 From: pravinkumar-exe <52107447+pravinkumar-exe@users.noreply.github.com> Date: Tue, 17 Jun 2025 15:38:42 +0530 Subject: [PATCH 2/3] Create internal-metadata-exposure.md This commit adds a placeholder file as part of the bug submission process for issue #116. The file references the exposure of internal infrastructure details to normal users via the endpoint 'https://app.aixblock.io//api/settings/installation-service/'. This is made from my forked branch to meet the required PR workflow. Looking forward to feedback. Signed-off-by: pravinkumar-exe <52107447+pravinkumar-exe@users.noreply.github.com> --- reports/internal-metadata-exposure.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 reports/internal-metadata-exposure.md diff --git a/reports/internal-metadata-exposure.md b/reports/internal-metadata-exposure.md new file mode 100644 index 00000000..f93c4a07 --- /dev/null +++ b/reports/internal-metadata-exposure.md @@ -0,0 +1,7 @@ +This pull request is a placeholder related to the infrastructure metadata exposure issue I reported in issue #116. + +The endpoint `https://app.aixblock.io/api/settings/installation-service/` reveals internal configuration data such as Docker image names, environment types, registry URLs, and version info — all of which should ideally be restricted to internal or admin roles. + +This placeholder commit is made from my fork as part of the official submission requirements. + +Looking forward to any feedback or next steps. Thank you! From 28d8fa1876a2c6448c8f633f7b176978905fa8c9 Mon Sep 17 00:00:00 2001 From: pravinkumar-exe <52107447+pravinkumar-exe@users.noreply.github.com> Date: Fri, 20 Jun 2025 01:18:05 +0530 Subject: [PATCH 3/3] Create ssrf-s3-endpoint-fix.md This commit adds a security fix for a critical SSRF vulnerability in the S3 storage configuration endpoint (PUT /api/storages/s3-server/{id}). The patch introduces: Validation to allow only trusted AWS S3 endpoints. Filtering of internal/private IP addresses via DNS resolution. Input validation for the bucket name. Suppressed verbose stack traces to avoid backend logic disclosure. Signed-off-by: pravinkumar-exe <52107447+pravinkumar-exe@users.noreply.github.com> --- reports/ssrf-s3-endpoint-fix.md | 74 +++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 reports/ssrf-s3-endpoint-fix.md diff --git a/reports/ssrf-s3-endpoint-fix.md b/reports/ssrf-s3-endpoint-fix.md new file mode 100644 index 00000000..1a3cf72f --- /dev/null +++ b/reports/ssrf-s3-endpoint-fix.md @@ -0,0 +1,74 @@ + This pull request corresponds to the vulnerability described in Issue #155(https://github.com/AIxBlock-2023/awesome-ai-dev-platform-opensource/issues/155) – SSRF in S3 Endpoint Validation. + + Bug Type: Server-Side Request Forgery (SSRF), Stack Trace Disclosure + Severity: Critical + +# Summary: + The S3 storage configuration feature allows authenticated users to submit arbitrary s3_endpoint URLs + along with any valid bucket name. The backend then makes a direct connection to the provided endpoint, + resulting in an SSRF vulnerability. This also leaks signed AWS headers (SigV4), and returns detailed + stack traces including exact file paths and internal code structure upon failure. + +- A valid-looking bucket name must be supplied to trigger the server-side request. + +# Fix: + - Block internal IP ranges (e.g., 127.0.0.1, 169.254.x.x, 10.x.x.x) + - Allow only valid AWS S3 domains + - Suppress sensitive stack trace data in error responses + +**Proposed Code Fix** +```python +import re +import socket +import logging +from urllib.parse import urlparse +from rest_framework.exceptions import ValidationError + +logger = logging.getLogger(__name__) + +def is_safe_url(url): + """ + Validates the s3_endpoint to: + - Block internal/private IPs (e.g., 127.0.0.1, 169.254.169.254, etc.) + - Allow only valid AWS S3 endpoints + """ + try: + parsed = urlparse(url) + hostname = parsed.hostname + if not hostname: + return False + + addr_info = socket.getaddrinfo(hostname, None) + for family, _, _, _, sockaddr in addr_info: + ip = sockaddr[0] + if ip.startswith(('127.', '169.254.', '10.', '192.168.', '172.')): + return False + + # Allow only S3 endpoints + allowed_pattern = r"^s3[.-]?(dualstack\.)?[a-z0-9-]+\.amazonaws\.com$" + if not re.match(allowed_pattern, hostname): + return False + + return True + except Exception as e: + logger.debug("is_safe_url validation failed: %s", e) + return False + + +# In models.py where validate_connection() is defined + +def validate_connection(self): + if not self.bucket or not re.match(r"^[a-zA-Z0-9.\-_]{1,255}$", self.bucket): + raise ValidationError("Invalid or empty bucket name.") + + if not is_safe_url(self.s3_endpoint): + raise ValidationError("Invalid or unsafe S3 endpoint URL.") + + try: + bucket_region = self.s3_client.get_bucket_location( + Bucket=self.bucket.rstrip('\n') + )["LocationConstraint"] + except Exception as e: + logger.debug("S3 connection validation error: %s", e) + raise ValidationError("Could not connect to the specified S3 bucket. Ensure the endpoint and bucket are correct.") +```