Scanner: semgrep Severity: medium Rule: gitlab-python_urlopen_rule-urllib-urlopen CWE: CWE-918
Description
The application was found passing in a non-literal value to the urllib methods which issue
requests. urllib supports the file:// scheme, which may allow an adversary who can control
the URL value to read arbitrary files on the file system.
To remediate this issue either hardcode the URLs being used in urllib or use the requests
module instead.
Example using the requests module to issue an HTTPS request:
import requests
# Issue a GET request to https://example.com with a timeout of 10 seconds
response = requests.get('https://example.com', timeout=10)
# Work with the response object
# ...
Location
File:scripts/check-eol-tables.py (line 60)
Code
with urllib.request.urlopen(request, timeout=TIMEOUT) as response:
Remediation
No change required unless the script accepts untrusted URLs; if it does, restrict the scheme to https and block file://.
## medium Finding
**Scanner:** semgrep
**Severity:** medium
**Rule:** gitlab-python_urlopen_rule-urllib-urlopen
**CWE:** CWE-918
### Description
The application was found passing in a non-literal value to the `urllib` methods which issue
requests. `urllib` supports the `file://` scheme, which may allow an adversary who can control
the URL value to read arbitrary files on the file system.
To remediate this issue either hardcode the URLs being used in urllib or use the `requests`
module instead.
Example using the `requests` module to issue an HTTPS request:
```
import requests
# Issue a GET request to https://example.com with a timeout of 10 seconds
response = requests.get('https://example.com', timeout=10)
# Work with the response object
# ...
```
### Location
**File:** `scripts/check-eol-tables.py` (line 60)
### Code
```
with urllib.request.urlopen(request, timeout=TIMEOUT) as response:
```
### Remediation
No change required unless the script accepts untrusted URLs; if it does, restrict the scheme to https and block file://.
---
*Fingerprint:* `033ea68e5e04c0dbe14608c9a5460914e0f5ae32522196d47058ba1876989366`
*Generated by compliance-scanner*
[Open in Prüfwerk / In Prüfwerk öffnen](https://pruefwerk.breakpilot.com/findings?target=6ae9aa2160f5d8045fc570a7)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
medium Finding
Scanner: semgrep
Severity: medium
Rule: gitlab-python_urlopen_rule-urllib-urlopen
CWE: CWE-918
Description
The application was found passing in a non-literal value to the
urllibmethods which issuerequests.
urllibsupports thefile://scheme, which may allow an adversary who can controlthe URL value to read arbitrary files on the file system.
To remediate this issue either hardcode the URLs being used in urllib or use the
requestsmodule instead.
Example using the
requestsmodule to issue an HTTPS request:Location
File:
scripts/check-eol-tables.py(line 60)Code
Remediation
No change required unless the script accepts untrusted URLs; if it does, restrict the scheme to https and block file://.
Fingerprint:
033ea68e5e04c0dbe14608c9a5460914e0f5ae32522196d47058ba1876989366Generated by compliance-scanner
Open in Prüfwerk / In Prüfwerk öffnen
Prüfwerk: In Prüfwerk als Fehlalarm (Regel) markiert.
Marked a false positive (rule) in Prüfwerk.