Skip to content

Unsigned PDF blocked as DocMDP P=1 because of an unreferenced signature object #9271

Description

@joudops

Describe the bug

LibreSign refuses to sign an unsigned PDF if it contains an unused signature dictionary with a DocMDP /P 1 entry, even though that object is not referenced by the document's active structure. It returns HTTP 422 with “This document has been certified with no changes allowed. You cannot add more signers to this document.” I originally reproduced this on 13.4.5 and still get the same error after upgrading to 13.4.7.

To reproduce

When trying to sign a PDF that was previously signed outside LibreSign, I got the error below.
I reproduced the same issue with simple test PDFs containing no real signatures or contract data.

The attached ZIP contains three reproduction files:

  1. 01-unsigned-control.pdf: a plain unsigned PDF.
  2. 02-unreferenced-docmdp-p1.pdf: the same document with an unused signature dictionary containing DocMDP /P 1.
  3. 03-rewritten-control.pdf: a rewritten copy of 02 with the unused object removed.

For each file:

  1. Upload it to LibreSign.
  2. Create a signing request.
  3. Open the request as the signer.
  4. Confirm signing.

I used two Nextcloud accounts that I control, one requesting the signature and the other signing.

Results from my tests on LibreSign 13.4.5:

File Result
01: unsigned baseline Signed successfully
02: unused DocMDP P1 object Blocked with HTTP 422 and the certification error
03: rewritten control Signed successfully

After upgrading to 13.4.7, the same signing error still occurs. The detailed three-file results above are from the original 13.4.5 tests.

The ZIP also contains a fourth PDF with an explicitly referenced P1 dictionary. That is a separate structural negative control with dummy signature bytes, not part of the three browser signing tests.

synthetic-reproducer.zip

Expected behavior

All three unsigned reproduction PDFs should pass the existing-certification check because none contains an active certification signature. An unused DocMDP object should not prevent signing. Genuine active P1 certifications should continue to block additional signatures.

Screenshots

Image

Operational System

Server: Debian, Nextcloud running in Docker

Browser Type and Version

Google Chrome / Edge

Libresign Version

13.4.7; originally reproduced on 13.4.5.

Nextcloud Server Version

33.0.10.1

Logs from Nextcloud Server

No LibreSign exception explaining the rejection.

The signing request returned HTTP 422 with the explicit DocMDP error in its JSON response, included below.

Logs from Developers tools

The failing request is:

POST /ocs/v2.php/apps/libresign/api/v1/sign/uuid/<test-request-uuid>?async=true

HTTP status: 422 Unprocessable Content

Response:

{
  "ocs": {
    "meta": {
      "status": "failure",
      "statuscode": 422,
      "message": ""
    },
    "data": {
      "action": 2000,
      "errors": [
        {
          "message": "This document has been certified with no changes allowed. You cannot add more signers to this document.",
          "code": 422
        }
      ]
    }
  }
}

Additional context

The failing test PDF has no AcroForm, signature fields, or catalog reference to a certification. It only contains an unused signature object with /P 1.

DocMdpHandler seems to scan the raw PDF and pick up that unused object anyway.

I have a possible fix and regression tests prepared and can submit a PR

Activity

  1. added theissue type on Oct 27, 2026
  2. vitormattos commented on Oct 27, 2026

    @vitormattos
    Member

    Thanks for the detailed report and the synthetic reproduction files. The separate control PDFs are particularly helpful.

    Please go ahead with a focused PR and regression tests. The key requirement is to distinguish an unreferenced signature dictionary from an active certification restriction, without weakening the protection against genuine DocMDP P=1 signatures.

    Please cover the unsigned control, the unreferenced P=1 object, the rewritten control, and a genuinely active certification case. For the negative control, a correctly signed certification fixture would be stronger evidence than dummy signature bytes.

    Keep the change focused on the DocMDP detection logic and reference this issue in the PR. Thanks for offering to work on this.

  3. joudops commented on Oct 28, 2026

    @joudops
    Author

    Hi @vitormattos, thanks for the guidance. I had an AI agent put together a patch and run some local tests but after looking through the changes I’m not confident I understand the PDF certification logic well enough to judge the fix or answer detailed questions about it. I’ll hold off on the PR for now, but happy to help test a fix on my setup when one is available.

  4. mateuscmtropical commented on Nov 10, 2026

    @mateuscmtropical

    Hi, I'd like to work on this one.

  5. mateuscmtropical commented on Nov 10, 2026

    @mateuscmtropical

    Hi, I've opened a PR for this: #9436

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions