Skip to content

F/os 303 digital signature security - #385

Merged
stankut merged 8 commits into
developfrom
f/OS-303_digital_signature_security
Nov 9, 2026
Merged

stankut merged 8 commits into
developfrom
f/OS-303_digital_signature_security

Conversation

@stankut

@stankut stankut commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

…_digital_signature_security

* commit '100e15f20d3d26f5d9950134282b74bea48aa960': (42 commits)
  312: Set #parents before building handler configuration forms
  Computed twig  encryption fix (#380)
  #321 deleting SaveToFile handler (#382)
  Fixing autocomplete fields usage (#381)
  Add missing trailing comma
  Applied map display settings consistently
  Remove delete state from handlers and require php 8.3
  Preparing 6.1.0
  Bumped os2web_datalookup version
  Apply coding standards
  Ensure no attachments with export type html are signed
  Run handler conditions before adding signature validation text
  Upgrading Gin theme
  OS-320 SBSYS child elements integration (#365)
  Fixing translation setting page (#359)
  Synching develop with master changes (#364)
  Preparing release 6.0.0
  #355 OS-314 children select element '#address_protection_help_text' fix
  352: Code cleanup
  352: Updated CHANGELOG
  ...

# Conflicts:
#	modules/os2forms_digital_signature/src/Plugin/WebformHandler/DigitalSignatureWebformHandler.php
@ds-bellcom

Copy link
Copy Markdown
Contributor

@MadNicGit vil I lave review på dette PR. Det er ikke et issue på dette PR af sikkerhedsmæssige årsager. Spørg evt. Gitte efter en mail jeg lige har sendt til Koordinationsgruppen.


/** @var \Drupal\webform\Plugin\WebformElementAttachmentInterface $elementPlugin */
$elementPlugin = $this->elementManager->getElementInstance($element);
$attachments = $elementPlugin->getEmailAttachments($element, $webformSubmission);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Am i right in saying that the resolve method is used in preSave() to render and get the actual content of the attachment file?

But then it is also used during signCallback() just for the purpose of finding the fid? Is it not possible to use a more light-weight method of finding the fid?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree that mechanism of fetching fid is quite complex.

One reason for the security refactoring was to prevent FID manipulation through the request. Previously, the callback route included {fid}:

before change:
path: '/os2forms_digital_signature/{uuid}/{hash}/sign_callback/{fid}'

after the change
path: '/os2forms_digital_signature/{uuid}/{hash}/sign_callback'

We therefore need to determine the target file server-side, using the submission and the handler’s configured attachment element. We could store the target when initiating signing, but resolving it from the submission avoids managing additional state.

However, you’re right that calling resolve() does unnecessary work here: the callback only needs the FID, while resolve() also loads or generates the attachment content. We could extract the element lookup and validation into a shared method so the callback skips that work.

Did you have another approach in mind? Open to suggestions 😃

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did not. Extracting the logic they have common into a separate shared method seems like a good idea!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

changed in 5e48bf7

Comment on lines +86 to +91
// SwiftMailer and Mime Mail consume filecontent rather than filepath.
if (($this->moduleHandler->moduleExists('swiftmailer')
|| $this->moduleHandler->moduleExists('mimemail'))
&& isset($attachment['filecontent'], $attachment['filepath'])) {
unset($attachment['filepath']);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't use either of these modules. Do you?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i checked, we don't use them either.

there are left there from the older versions. I think this piece is still valid, should anyone start using these or similar modules.

but if that bothers you, we can also remove it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If neither of us use it i think we should remove it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@jekuaitk changed in 5e48bf7

@MadNicGit

Copy link
Copy Markdown

Hej @ds-bellcom
Jeg skal blot være sikker på at I så @jekuaitk lavede review på denne.

@ds-bellcom

Copy link
Copy Markdown
Contributor

Hej @ds-bellcom Jeg skal blot være sikker på at I så @jekuaitk lavede review på denne.

Yes, det har jeg set. Jeg håber Stan kan få det færdiggjort inden længe.

@jekuaitk
jekuaitk self-requested a review November 9, 2026 14:32

@jekuaitk jekuaitk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@stankut
stankut merged commit 1151d4f into develop Nov 9, 2026
7 of 8 checks passed
@stankut
stankut deleted the f/OS-303_digital_signature_security branch November 9, 2026 15:27
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.

4 participants