Skip to content

Sanitize audit logs by removing user-supplied username from Logger.Info messages in GetUser handler. #11

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zeropath-ai-dev[bot]
Copy link

Summary

  • The Vulnerability Description: The handler previously logged the raw username from HTTP request parameters directly, allowing untrusted user input to be stored verbatim in audit logs, exposing the application to log injection and potential tampering.
  • This Fix: The patch removes the inclusion of the raw user-supplied username value from all audit log entries, logging only generic status messages without user data.
  • The Cause of the Issue: Directly embedding user-generated data into logs without proper sanitization or validation introduced a risk of log injection and data tampering.
  • The Patch Implementation: The updated code replaces all instances of es.Logger.Info(fmt.Sprintf(..., username)) with messages that do not include the username, ensuring only static strings are written to logs.

Vulnerability Details

  • Vulnerability Class: Natural Language Rule Violation
  • Severity: 0.0
  • Affected File: owasp-top10-2016-mobile/m5/panda_zap/server/routes/user.go
  • Vulnerable Lines: 68-73

Code Snippets

diff --git a/owasp-top10-2016-mobile/m5/panda_zap/server/routes/user.go b/owasp-top10-2016-mobile/m5/panda_zap/server/routes/user.go
index 9b5c2676..fc66e62a 100644
--- a/owasp-top10-2016-mobile/m5/panda_zap/server/routes/user.go
+++ b/owasp-top10-2016-mobile/m5/panda_zap/server/routes/user.go
@@ -65,13 +65,13 @@ func (es *EchoServer) GetUser(c echo.Context) error {
 
 	userFromDB, err := es.Database.GetUser(username)
 	if err != nil {
-		es.Logger.Info(fmt.Sprintf("User '%s' not found in the database", username))
+		es.Logger.Info("User not found in the database")
 
 		return c.JSON(http.StatusNotFound,
 			map[string]string{"result": "fail", "message": err.Error()})
 	}
 
-	es.Logger.Info(fmt.Sprintf("User '%s' found in the database", username))
+	es.Logger.Info("User found in the database")
 	return c.JSON(http.StatusOK, userFromDB)
 }
 

How to Modify the Patch

You can modify this patch by using one of the two methods outlined below. We recommend using the @zeropath-ai-dev bot for updating the code. If you encounter any bugs or issues with the patch, please report them here.

Ask @zeropath-ai-dev!

To request modifications, please post a comment beginning with @zeropath-ai-dev and specify the changes required.

@zeropath-ai-dev will then implement the requested adjustments and commit them to the specified branch in this pull request. Our bot is capable of managing changes across multiple files and various development-related requests.

Manually Modify the Files

# Checkout created branch:
git checkout zvuln_fix_natural_language_rule_violation_1754369403717951

# if vscode is installed run (or use your favorite editor / IDE):
code owasp-top10-2016-mobile/m5/panda_zap/server/routes/user.go

# Add, commit, and push changes:
git add -A
git commit -m "Update generated patch with x, y, and z changes."
git push zvuln_fix_natural_language_rule_violation_1754369403717951

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.

0 participants