Communication over HTTP

Requests over HTTP

Description

HTTP sends requests and responses in plaintext and does not authenticate the server.

Potential impact

Data can be read or altered in transit. Exposed credentials can give access to the account.

Remediation

Require HTTPS with TLS 1.2 or later on the server and in the application. Keep server certificate verification enabled.

Examples

Before

python
# Unsafe HTTP requests
import requests

response = requests.get('http://example.com/api/data')

After

python
# Safe HTTPS requests
import requests

response = requests.get('https://example.com/api/data')

Explanation

The two requests.get calls use the same path. The second uses HTTPS and keeps Requests’ default certificate verification. Passing verify=False would disable that check.

References