Opened 2 years ago

Closed 17 months ago

#22990 closed Cleanup/optimization (fixed)

Sensitive POST data leaks from complex variables

Reported by: Vlastimil Zíma Owned by: Vlastimil Zíma
Component: Core (Other) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


Using @sensitive_post_parameters() decorator does not help much, because POST data are leaked through variables which wraps the request, such as dictionaries and tuples. Since there are a lot of wrappers and decorators this is fairly common problem.

I have added temporarily a ValueError into UserAdmin.add_view and checked the result. The password is leaked on several occasions. Look for 'secret' in the attached email.

Attachments (1)

sensitive-leaked.eml (207.4 KB) - added by Vlastimil Zíma 2 years ago.
Error email with sensitive data

Download all attachments as: .zip

Change History (14)

Changed 2 years ago by Vlastimil Zíma

Attachment: sensitive-leaked.eml added

Error email with sensitive data

comment:1 Changed 2 years ago by Vlastimil Zíma

This is most likely a generic version of #21098.

comment:2 Changed 2 years ago by Tim Graham

After working on #21098, I think investing more time in trying to make @sensitive_post_parameters() more secure is a losing battle. We should at least document that it's not foolproof, as well as the inherent insecurity in error reporting by email.

comment:3 Changed 2 years ago by Vlastimil Zíma

Wouldn't be worth it to handle sensitive post parameters in build_request_repr

comment:4 Changed 2 years ago by Tim Graham

Perhaps; I'm not sure much complexity it would add. Are you interested in writing a patch?

comment:5 Changed 2 years ago by Tim Graham

Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

comment:6 Changed 2 years ago by Vlastimil Zíma

Owner: changed from nobody to Vlastimil Zíma
Status: newassigned

I'll give it a try.

comment:7 Changed 2 years ago by Vlastimil Zíma

Has patch: set

I finally created a patch which solves this issue, pull request is at github:

I've found a serious flaw in the tests of the technical 500 error. The tests directly called the view which rendered technical 500 page itself. This greatly cut down the traceback to single frame, thus hiding potential leakage occuring on higher levels in production environments. So, I've refactored the tests to use test client and common handling of unhandled exception.

Further issues:

  • Some important data may be hidden in DEBUG mode. I'll investigate it further after this ticket is completed.
  • Because of the complexity of the problem, data can't be marked as sensitive only for one channel (e.g. HTML error mails) and affected values should be generally hidden in all cases. IMHO EXCEPTION_REPORTER_FILTER should be replaced with SANITIZER to remove any confusion which may occur from seeing exception reporter filter in request POST representation.
  • Test client may have an attribute to disable reraising the exception from the view.

comment:8 Changed 23 months ago by Berker Peksag

Patch needs improvement: set

comment:9 Changed 21 months ago by Asif Saifuddin Auvi

Owner: changed from Vlastimil Zíma to Asif Saifuddin Auvi

comment:10 Changed 17 months ago by Vlastimil Zíma

Owner: changed from Asif Saifuddin Auvi to Vlastimil Zíma

Finally I had a bit of time to update the patch. It is in new PR

comment:11 Changed 17 months ago by Vlastimil Zíma

Patch needs improvement: unset

comment:12 Changed 17 months ago by Tim Graham

Patch needs improvement: set

comment:13 Changed 17 months ago by Tim Graham

Resolution: fixed
Status: assignedclosed

Fixed by #25099

Note: See TracTickets for help on using tickets.
Back to Top