phdphd Posted October 9, 2021 Share Posted October 9, 2021 Hi All, Is there a security risk with PDF files in the following registration process ? 1. A user fills in a form with values that are then regex-checked and stored into session variables. 2. The user details are sent to a table using a parameterized query. 3. The user goes through a payment process. 4. When the user has successfully paid, an invoice as a PDF file is stored on the server and also sent by mail to the user as an attachement. This PDF file is built up with some of the session variables’ values previously entered by the user. Is there any risk that those values cause issues server side (when the file is stored) or user side (when the user opens the email or the attached PDF file) ? Does any sanitizing need to be done for values to be included into a PDF file? Thank you! Regards, PhD Quote Link to comment https://forums.phpfreaks.com/topic/313923-sanitizing-pdf-files/ Share on other sites More sharing options...
ginerjm Posted October 9, 2021 Share Posted October 9, 2021 One shouldn't store/save sensitive values. Once the input values are used to authorize a user, you should use a generated token to recognize the authenticity of the user from that point on. As for a pdf I don't believe you have to worry about that. 1 Quote Link to comment https://forums.phpfreaks.com/topic/313923-sanitizing-pdf-files/#findComment-1590823 Share on other sites More sharing options...
requinix Posted October 9, 2021 Share Posted October 9, 2021 Nicer than storing generated PDFs on your server is generating them at the time they're needed. Because, at least in the case of invoices, the data supporting its contents shouldn't ever change. 1 Quote Link to comment https://forums.phpfreaks.com/topic/313923-sanitizing-pdf-files/#findComment-1590837 Share on other sites More sharing options...
Psycho Posted October 10, 2021 Share Posted October 10, 2021 8 hours ago, requinix said: Nicer than storing generated PDFs on your server is generating them at the time they're needed. Because, at least in the case of invoices, the data supporting its contents shouldn't ever change. Generally, I would agree with that. However, I wonder if there would be legal reasons for keeping a copy of the invoice that was sent. Yes, another copy could be generated later and would be the same - if the code had not changed. But, if there was any type of legal action and the company needed to provide records of the invoices that were sent, I don't know if regenerating a copy would be adequate. They might have to also prove that none of the code changed that generated the invoice and if the code had changed they might have to prove what the invoice would have looked like at the time it was generated previously. 1 Quote Link to comment https://forums.phpfreaks.com/topic/313923-sanitizing-pdf-files/#findComment-1590848 Share on other sites More sharing options...
phdphd Posted October 10, 2021 Author Share Posted October 10, 2021 Hi All, Thank you for your answers. When the invoice is sent by mail to the user, it is also BCC'd to the webmaster. By doing this I have a copy of the invoice as it was sent, at the time it was sent. However, storing it on the server may be useful if for any reason, sending the mail fails. In this case, I just need to grab the invoice from the server and email it manually. Another advantage of storing it on the server is if I need to print a copy of the invoice. I would not need to search for it in the email system. Quote Link to comment https://forums.phpfreaks.com/topic/313923-sanitizing-pdf-files/#findComment-1590852 Share on other sites More sharing options...
ginerjm Posted October 10, 2021 Share Posted October 10, 2021 But - do not save it in a table. Have a folder for these and save the filename in the customer's records but save the pdf as its own file. 1 Quote Link to comment https://forums.phpfreaks.com/topic/313923-sanitizing-pdf-files/#findComment-1590853 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.