Skip to content

Security: No Timeout on HTTP Requests Leading to Potential Denial of Service#2103

Open
barttran2k wants to merge 1 commit intoOWASP:masterfrom
barttran2k:contribai/fix/security/no-timeout-on-http-requests-leading-to-p
Open

Security: No Timeout on HTTP Requests Leading to Potential Denial of Service#2103
barttran2k wants to merge 1 commit intoOWASP:masterfrom
barttran2k:contribai/fix/security/no-timeout-on-http-requests-leading-to-p

Conversation

@barttran2k
Copy link
Copy Markdown

Problem

Multiple scripts make HTTP requests using requests.get() and requests.post() without specifying a timeout parameter. If the remote server is unresponsive, the script will block indefinitely, potentially causing resource exhaustion or hanging CI/CD pipelines.

Severity: low
File: scripts/Identify_Old_Issue_And_PR.py

Solution

Add a timeout parameter to all requests.get() and requests.post() calls. For example: response = requests.get(ISSUE_API, timeout=30)

Changes

  • scripts/Identify_Old_Issue_And_PR.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

Multiple scripts make HTTP requests using `requests.get()` and `requests.post()` without specifying a `timeout` parameter. If the remote server is unresponsive, the script will block indefinitely, potentially causing resource exhaustion or hanging CI/CD pipelines.

Affected files: Identify_Old_Issue_And_PR.py

Signed-off-by: Trần Bách <[email protected]>
@mackowski
Copy link
Copy Markdown
Collaborator

Approved, but please fix linter error

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds explicit HTTP timeouts to prevent the watchdog script from hanging indefinitely on unresponsive endpoints.

Changes:

  • Add timeout=30 to the GitHub Issues API requests.get() call.
  • Add timeout=30 to the Slack webhook requests.post() call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to 97
response = requests.post(sys.argv[1], headers=request_headers, data=message, timeout=30)
if response.status_code != 200:
print("Cannot send notification to slack: HTTP %s received!" % response.status_code)
sys.exit(2) No newline at end of file
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requests.post(..., timeout=30) can raise requests.exceptions.Timeout/RequestException and currently would terminate the script with an unhandled exception. Consider catching requests.exceptions.RequestException around the Slack webhook call and exiting with code 2 while printing a concise error (including that a timeout occurred).

Copilot uses AI. Check for mistakes.
# Grab the list of open Issues/PR
buffer = "Grab the list of open Issues/PR via the GitHub API...\n"
response = requests.get(ISSUE_API)
response = requests.get(ISSUE_API, timeout=30)
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions "multiple scripts" lacking request timeouts, but this change only updates Identify_Old_Issue_And_PR.py. For example, scripts/Generate_RSS_Feed.py and scripts/Generate_Technologies_JSON.py still call requests.get(...) without a timeout (as of current main). Either expand the fix set or narrow the PR description/scope accordingly.

Copilot uses AI. Check for mistakes.
# Grab the list of open Issues/PR
buffer = "Grab the list of open Issues/PR via the GitHub API...\n"
response = requests.get(ISSUE_API)
response = requests.get(ISSUE_API, timeout=30)
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requests.get(..., timeout=30) can raise requests.exceptions.Timeout/RequestException before status_code is available. Right now that would crash the script with a traceback. Wrap this call in a try/except requests.exceptions.RequestException and exit with code 1 (and a clear message) on network/timeout failures.

Suggested change
response = requests.get(ISSUE_API, timeout=30)
try:
response = requests.get(ISSUE_API, timeout=30)
except requests.exceptions.RequestException as exc:
print("Cannot load the list of Issues/PR content: %s" % exc)
sys.exit(1)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants