Skip to content

Fix credential exposure in keygen() tracebacks#55

Open
bubblegum-h wants to merge 2 commits intokevinsteves:masterfrom
bubblegum-h:password-leak-fix
Open

Fix credential exposure in keygen() tracebacks#55
bubblegum-h wants to merge 2 commits intokevinsteves:masterfrom
bubblegum-h:password-leak-fix

Conversation

@bubblegum-h
Copy link

Summary

Prevent API passwords from being exposed in exception tracebacks when keygen() fails.

Problem

The keygen method builds a query dict containing the password ({'type': 'keygen', 'user': '...', 'password': '...'}). On PanXapiError, the traceback can include this local variable, exposing credentials in logs and error reports.

Solution

Clear the password from the query dict in a try/finally block so it is removed before any exception propagates. By the time the traceback is captured, the password is no longer in the query dict.

Impact

  • No change to API behavior; the password is only removed after the request is sent.
  • query is used only by __api_request; no other references are affected.

@bubblegum-h
Copy link
Author

@kevinsteves, I tried reach you via email. I haven't gotten back from you. Please have a look at this PR. Thanks

@kevinsteves
Copy link
Owner

Thank you for your report.

Can you comment on the attached
X.txt
diff.

  • makes the intent clearer
  • is next to the password usage

@bubblegum-h
Copy link
Author

Thanks @kevinsteves for the suggestion. i updated the code, you can check.

kevinsteves added a commit that referenced this pull request Mar 24, 2026
Clear password from query object immediately after use.
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.

2 participants