Problem/Motivation
If I try to use any url token in an email handler while a webform is configured to not save results, then an exception is thrown:
Drupal\Core\Entity\EntityMalformedException: The "webform_submission" entity cannot have a URI as it does not have an ID in Drupal\Core\Entity\EntityBase->toUrl() (line 161 of /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php).
Steps to reproduce
Use a token such as [webform_workflow:transition-url:?:unaliased] on a handler on a form which is configured not to save submissions and submit the form.
Proposed resolution
I know this is not a real life situation because workflows cannot be used if the submissions are not saved, but it was mentioned in a security audit and provides (in theory) an attack vector for a malicious user. Simple check and silently failing will prevent the exception to be thrown. Added logging will help the site-builder to solve the problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | prevent-exception-3556600-3.patch | 1.41 KB | merilainen |
Issue fork webform_workflows_element-3556600
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
merilainen commentedMR created, patch provided for composer.
Comment #4
mably commented@merilainen could you please share a few more details on how to reproduce the issue?
I would like to test the MR before merging. Thanks.
Comment #5
merilainen commentedI have written in the ticket description:
"Use a token such as [webform_workflow:transition-url:?:unaliased] on a handler on a form which is configured not to save submissions and submit the form."
So if you configure "Disable saving of submissions" in the form setting and then go and add an email handler for example which will try to use a webform_workflow url token such as
[webform_workflow:transition-url:?:unaliased]this will produce an error because entity is not created and thus a url cannot be provided for the submission. So this is incorrect configuration but it causes an exception which malicious user could use to break a site.Comment #6
mably commented@merilainen thanks for you comment, I've been able to reproduce the problem locally.
Looks like we might still want to generate URL for old existing submissions even after having disabled submission saving at the webform level.
May be we could simply disable URL token processing if the submission has no
id?We could do something like this (MR 41):
This solution doesn't replace the tokens, but it's probably better than hiding the problem in empty urls or link hrefs.
We could also simply disable the links but still display the corresponding labels as plain text for the
transition-linktoken.What do you think?
Comment #8
mably commented