Sensitive information in comments

Sensitive information is included in comments.

Description

Passwords, tokens, API keys, and internal URLs in Python comments can travel with source packages or deployment artifacts.

Potential impact

Anyone with a copy may still use a valid credential after the source file changes.

Remediation

Revoke the exposed credential, issue a replacement, and update the services that use it. Remove sensitive values from the comment and review repository history for copies.

Examples

Before

python
# password = "prod-db-password"

After

python
# password is loaded from the secret manager at runtime

The example replaces the password with a comment about its runtime source. The application still needs to load the value from the secret manager.

References