Skip to content

Potential fix for code scanning alert no. 3: Clear-text logging of sensitive information #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025

Conversation

krishnprakash
Copy link
Owner

Potential fix for https://github.com/krishnprakash/cloudflare-docs/security/code-scanning/3

To fix the problem, we need to ensure that sensitive information such as client_secret is not logged in clear text. Instead, we can log a message indicating that a service token was created without including the sensitive details. This way, we maintain the functionality of informing the user about the creation of the service token without exposing sensitive information.

We will modify the logging statement on line 149 to exclude the client_secret. We will also ensure that any other sensitive information is not logged in clear text.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…nsitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@@ -146,7 +146,7 @@
service_token_name = input('Please input name for service token > ')
client_id, client_secret = request_create_service_token(service_token_name)
print(
f"Created service token with client_id {client_id} and client_secret {client_secret}. You may want to save these secrets.")
f"Created service token with client_id {client_id}. Please save the client_secret securely.")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (secret)
as clear text.

Copilot Autofix

AI 2 months ago

To fix the problem, we need to ensure that sensitive information such as client_secret is not logged. Instead of logging the client_secret, we can log a message indicating that the service token was created without revealing the sensitive information. This can be achieved by modifying the log message to exclude the client_secret.

  • Modify the log message on line 149 to exclude the client_secret.
  • Ensure that the log message still provides useful information without exposing sensitive data.
Suggested changeset 1
public/cloudflare-one/static/authenticated-doh.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/public/cloudflare-one/static/authenticated-doh.py b/public/cloudflare-one/static/authenticated-doh.py
--- a/public/cloudflare-one/static/authenticated-doh.py
+++ b/public/cloudflare-one/static/authenticated-doh.py
@@ -148,3 +148,3 @@
     print(
-        f"Created service token with client_id {client_id}. Please save the client_secret securely.")
+        f"Created service token with client_id {client_id}. Please save the client_secret securely and do not log it.")
 
EOF
@@ -148,3 +148,3 @@
print(
f"Created service token with client_id {client_id}. Please save the client_secret securely.")
f"Created service token with client_id {client_id}. Please save the client_secret securely and do not log it.")

Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@krishnprakash krishnprakash marked this pull request as ready for review March 13, 2025 18:04
@krishnprakash krishnprakash merged commit 18c4c82 into production Mar 13, 2025
9 of 10 checks passed
@krishnprakash krishnprakash deleted the alert-autofix-3 branch March 13, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant