Skip to content

fix(docmdp): accept DSS and document timestamp updates after certification - #9556

Merged
vitormattos merged 11 commits into
LibreSign:mainfrom
no84by:fix/docmdp-allow-dss
Nov 24, 2026
Merged

vitormattos merged 11 commits into
LibreSign:mainfrom
no84by:fix/docmdp-allow-dss

Conversation

@no84by

@no84by no84by commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #9534
Part of #8946
Related: #9667 (separate PR)

Summary

ISO 32000-2 §12.8.2.2.1 and ETSI EN 319 142-1 allow validation-only incremental updates (DSS/VRI, certificates, CRLs, OCSP responses and document timestamps) after PDF certification. LibreSign previously reported these updates as DocMDP violations, including at P=1.

This change recognizes validation-only revisions at DocMDP P=1, P=2 and P=3 without allowing unrelated changes to page content, forms, annotations or document structure.

Implementation

  • Reuse DocMdpValidationDataInspector::hasOnlyValidationDataUpdates() from pdf-signature-validator v0.6.1 rather than maintaining a duplicate PDF revision parser in DocMdpHandler.
  • Use PdfSignatureInventoryReader to locate the active certification signature, determine its signed revision boundary and exclude orphaned signature dictionaries from conclusive revision counts. Retain the legacy fallback when inventory parsing is inconclusive.
  • Apply the validation-only exemption before the existing DocMDP modification checks. Malformed or non-validation changes are not exempt; structural classification does not replace cryptographic signature verification.
  • Extend positive and negative tests for DSS, document timestamps, multiple incremental revisions, P=1/2/3, active versus orphaned signatures and prohibited changes.

CI follow-up fixes

The branch also includes two narrowly scoped fixes for failures exposed while validating the PR:

  • WorkerStarterTest: wait for the worker's completion marker content, not merely the existence of its file.
  • Policy workbench: discard stale asynchronous group/user search results, avoid filtering server-provided options a second time and keep the group selector dropdown inside its dialog. The Playwright selection and persistence assertions remain enabled.

These changes are separate from the DocMDP logic and are visible in the diff.

How to test

  1. Certify a PDF with DocMDP P=1, P=2 and P=3.
  2. Add only DSS data, a document timestamp or successive validation-only incremental revisions (for example, with pyHanko). Confirm the certification modification check permits them.
  3. Append a prohibited page-content, annotation, form or structure change. Confirm it remains a DocMDP violation, even if DSS data is present.
  4. Verify signature cryptography separately, including active certification signatures and orphaned signature dictionaries.

Validation

  • DocMdpHandlerTest: 81 tests, 153 assertions passed locally on PHP 8.3, 8.4 and 8.5.
  • DocMdpHandlerValidationDataTest includes native-engine integration and negative regression scenarios.
  • Focused policy-workbench Vitest: 98 tests passed; ESLint, Vue type checking and JavaScript build passed locally.
  • GitHub Actions checks: 21 workflows passed on 355c21c, including PHPUnit, Behat and Playwright (verified 2026-11-23). Consult the live checks for subsequent commits.

The original contributor commit and authorship are preserved. Follow-up commits are cryptographically signed and DCO-compliant; no rebase or force-push was used. Parts of the implementation were developed with AI assistance.

Maintainer review and final merge remain human decisions.

…ation

ISO 32000-2 12.8.2.2.1 and ETSI EN 319 142-1 5.4 exempt incremental
updates that only add a DSS dictionary (VRI, Certs, CRLs, OCSPs) or a
document timestamp from DocMDP restrictions. The validation classified
such an update as an unknown modification, so a certified document
became invalid as soon as long-term validation data was added, at every
DocMDP level.

Before classifying the modification, parse the bytes after the certified
revision strictly as incremental updates: indirect objects, a classic
xref table listing exactly those objects at their offsets, a trailer
whose /Root, /Info and /Prev match the certified revision and has no
/Encrypt, and startxref. Xref streams, unlisted or unparsable bytes and
object streams mean the update is not validation data only. The
certified revision is read through its classic xref tables.

New objects must use numbers from the certified /Size on. Of the
existing objects, an update may only rewrite the catalog (/DSS,
/Extensions, /Version), the AcroForm (/SigFlags, timestamp fields
appended to /Fields), a page (timestamp fields appended to /Annots) and
the information dictionary (/ModDate, /Producer). A new field must be an
invisible document timestamp field (zero-area /Rect, no /Kids, /Parent,
/A or /AA) whose value is a new /DocTimeStamp with /SubFilter
/ETSI.RFC3161; any other new signature, field or annotation keeps the
update a violation.

Rewritten objects are compared in a canonical form (sorted keys, names
with #xx escapes decoded, strings by their bytes, duplicate keys
rejected, bounded nesting), since LTV tools rewrite the catalog and the
information dictionary with their own formatting.

Signed-off-by: no84by <50858621+no84by@users.noreply.github.com>

Copy link
Copy Markdown
Member

Hi! The dependency updates are now fully merged and available on LibreSign's main branch.

Could you please rebase this PR onto the latest main and adapt the implementation to use the shared validator?

In particular:

  1. Replace the duplicated PDF parsing logic in DocMdpHandler with DocMdpValidationDataInspector::hasOnlyValidationDataUpdates().
  2. Use the active-signature inventory rather than raw /ByteRange matching to identify the certification signature.
  3. Preserve the existing DocMDP P=1/P=2/P=3 behavior and the regression tests for valid and forbidden modifications.
  4. Coordinate the signature inventory changes with fix(docmdp): ignore orphaned signatures in revision summary #9667 to avoid overlapping or inconsistent implementations.
  5. Run the relevant tests and CI checks after resolving the rebase conflicts.

The required dependency APIs are already available under the OCA\Libresign\Vendor\LibreSign\PdfSignatureValidator namespace.

The goal is to keep the functional improvements and security regression coverage from your contribution while delegating structural PDF inspection to the shared library.

Thanks!

@vitormattos vitormattos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes before merge. The required validator v0.6.1 and scoped 3rdparty update are now merged into LibreSign's main, but this PR still duplicates security-sensitive PDF revision parsing and needs to be rebased and adapted to the shared APIs.

Please address the concrete items in the maintainer comment: use DocMdpValidationDataInspector, rely on the active signature inventory, preserve P=1/P=2/P=3 semantics and regression coverage, coordinate with #9667, and rerun CI after resolving conflicts. We can re-review the updated implementation once these changes are available.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos

Copy link
Copy Markdown
Member

/backport to stable35

@vitormattos

Copy link
Copy Markdown
Member

/backport to stable34

@backportbot-libresign backportbot-libresign Bot added the backport-request Request to backport a change to supported stable branches label Nov 24, 2026
@vitormattos

Copy link
Copy Markdown
Member

/backport to stable33

@vitormattos
vitormattos merged commit fc5c1a6 into LibreSign:main Nov 24, 2026
78 checks passed
@backportbot-libresign backportbot-libresign Bot removed the backport-request Request to backport a change to supported stable branches label Nov 24, 2026
vitormattos added a commit that referenced this pull request Nov 25, 2026
The active-signature inventory implementation is already on main via #9556.
Remove the superseded revision-count shortcut and cover orphan-only and
mixed active-certification scenarios with real incremental revisions.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
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.

Post-signing DSS addition breaks DocMDP validation

2 participants