Skip to content
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

Saving the form invalidates the signature of the PDF file when the PDF is a form #14816

Open
fgerges opened this issue Apr 21, 2022 · 7 comments

Comments

@fgerges
Copy link

fgerges commented Apr 21, 2022

Attach (recommended) or Link to PDF file here: see attachment

Configuration:

Steps to reproduce the problem:

  1. set adobe acrobat reader as default viewer for PDF file to activate it on pdf file download
  2. go on https://mozilla.github.io/pdf.js/web/viewer.html
  3. open the pdf in attachment
  4. enter information in the fields of the form
  5. click on the download button (which saves the pdf and triggers its download and then its opening in Adobe acrobat reader)

What is the expected behavior? (done with Adobe Acrobat Reader 2022.001.20117 64 bits)
image

What went wrong?
image

formulaire_signé.pdf

@Snuffleupagus
Copy link
Collaborator

Duplicate of #13351

@Snuffleupagus Snuffleupagus marked this as a duplicate of #13351 Apr 21, 2022
@fgerges
Copy link
Author

fgerges commented Apr 21, 2022

why did you close the bug, what I'm reporting has nothing to do with signature verification in #13351
The problem is on the save command which destroys the signature present in the PDF form, take a look at the tittle and at my post.
Thank you to re-open the issue

@Snuffleupagus
Copy link
Collaborator

Note that we currently only support displaying existing signatures, and nothing else unfortunately.

Hence we don't have any code to handle signatures on saving, since that'd require issue #13351 to be implemented in order to work; hence why it's marked as a duplicate.

@fgerges
Copy link
Author

fgerges commented Apr 21, 2022

As said before, nothing to do with the display or the validation of the signature.

The problem is in the save method, when pdfjs puts the forms data into the pdf structure, which are annotation structures I think, and the method puts it in a wrong format, and that's the problem and the cause of the destruction of the signature. So, as said before, it's a bug on the save method, nothing more

You can see on the first screenshot, how the data should be stored

So, please could you re-open the issue

@marco-c
Copy link
Contributor

marco-c commented Apr 21, 2022

Are you seeing a different behavior if you save with Adobe Reader? I would expect the signature to be stripped since you are effectively modifying the PDF

@fgerges
Copy link
Author

fgerges commented Apr 21, 2022

@marco-c the first capture is done with Adobe Reader, it's why i said it's like that the data should be stored

a zone for storing data is reserved, and therefore does not cancel the signature in normal operation, as in Adobe Reader

@pr-apes
Copy link

pr-apes commented Apr 23, 2024

@fgerges,

by pressing Ctrl when opening Acrobat, you may choose the language (so that screenshots are in English).

Acrobat saves your signed document without signature corruption:

amended-doc

PDF.js (with Firefox in my case) corrupts the signature:

invalid-sig

The PDF specification explicitly mentions this case (from its publicly reachable version):

If a signed document is modified and saved by incremental update (see 7.5.6, “Incremental Updates”), the data corresponding to the byte range of the original signature is preserved. Therefore, if the signature is valid, it is possible to recreate the state of the document as it existed at the time of signing.

So the issue would be to use incremental updates to save modifications in an already signed document.

That being said, I don't think this is a good idea to fix this issue.

This might be used to trick users into believing that a document with unsigned amendments constitutes its actually signed version.

Unless I'm missing something, this may cause much more harm that good. This is not a technical issue.

I don't think it is obvious (for not technically-minded persons) what unsigned amendments are (especially when the icon from the signature pane is green).

Just in case it might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants