Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
24 Nov 2023 at 15:14 UTC
Updated:
11 Mar 2024 at 08:29 UTC
Jump to comment: Most recent
Comments
Comment #2
avpadernoThank you for applying!
Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.
The important notes are the following.
phpcs --standard=Drupal,>DrupalPracticeon the project, which alone fixes most of what reviewers would report.To the reviewers
Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.
The important notes are the following.
For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.
Comment #3
avpadernoComment #4
vishal.kadam1. FILE: kontainer.module
The description for a module is Hook implementations for the [module name] module. where [module name] is the module name given in the .info.yml file.
2. The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.
Function and method declarations are written on a single line.
src/Plugin/Field/FieldFormatter/KontainerCdnFormatter.php
src/Plugin/Field/FieldWidget/KontainerCdnItemWidget.php
src/Plugin/Field/FieldWidget/KontainerReferenceItemWidget.php
src/Plugin/Validation/Constraint/KontainerLinkConstraintValidator.php
src/Plugin/media/Source/KontainerFileAssetDeriver.php
src/Service/KontainerService.php
src/Form/KontainerConfigForm.php
src/Controller/KontainerController.php
Comment #5
slogar32 commentedComment #6
vishal.kadamComment #7
slogar32 commentedThank you for your feedback!
I have fixed everything from your list of findings. The changes have been pushed to the 1.x branch. If there is something more to do, please let me know.
Comment #8
vishal.kadamdocsandmainare wrong names for a branch and should be removed. Release branch names always end with the literal .x as described in Release branches.The only exception is for the main branch, which is actually not fully supported on drupal.org and should be avoided.
Comment #9
slogar32 commentedBoth branches have been deleted.
Comment #10
slogar32 commentedI am changing the issue priority as per issue priorities.
Comment #11
slogar32 commentedComment #12
trigve hagen commentedThere are a couple of the phpcs error in this file. Code looks good. No duplication of code or functionality that I could see. README.md looks good, No security vulnerabilities that I can see off hand. Moving to Reviewed and tested if no one objects.
FILE: /var/www/html/global/web/modules/contrib/kontainer/js/kontainer.js
---------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------
3 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
7 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
28 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
34 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
63 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
63 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
63 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------
Time: 3.75 secs; Memory: 12MB
Comment #13
slogar32 commentedThanks for the extra review! Yeah, this is in the JS file, but you can't write FALSE, TRUE and NULL upper case in JS, so this Drupal standard should be ignored for the Javascript file, DrupalPractice doesn't return any errors for it also.
Comment #14
klausimanual review:
Please fix the 3 security vulnerabilities and check your code for other similar issues. And please don't remove the security tag, we keep that for statistics and to show examples of security problems.
Comment #15
slogar32 commentedThank you very much for the review!
I have some questions/information about your points:
4. I didn't put any access requirements to the route definition in the routing.yml file, because I check this dynamically in code (see checkAccess function in KontainerService.php, which is called in the createEntities function in the controller for this route). I did this, because the media type is fetched dynamically from the JSON response each time from the Kontainer DAM, or decided based on the module configurations (if CDN is set as media source, then it is set to this value which is not in the response from the JSON.) So I would leave this as it is, if you do not see it as an access bypass vulnerability, based on this explanation. If not, I can just add all the 5 Kontainer media types permissions, which come with the module directly to the route definition (and leave the custom access check in code).
3. I am not exactly sure what I need to do here. I am generating the CSRF token based on the route path, then I add this token to the ajaxTrustedUrl drupalSettings, where the token is added as a query parameter to the media path only (and not the URL), and I also add It to custom drupalSettings. Then in the Javascript library, where the actual call to the route is made (
url: Drupal.url(url) + '?token=' + drupalSettings.kontainer.token,) I build the URL from the values, that are generated in the widget class. I was doing this based on this example here: https://drupal.stackexchange.com/questions/221251/generating-url-with-csrf-tokenSo what I see that I could change here is to actually generate the URL object in the widget class by adding the CSRF token as the URL query parameter directly to the object, and then add this URL object to the drupalSettings, instead of building the URL in the Javascript library with Drupal.url(). But the CSRF token generation would stay as it is. Is this the direction, that you are pointing me to? If not, could you please provide me an explanation or an example, that would lead me in the right direction? Thanks!
Points 1 and 2 are clear to me. I will push those fixes by the end of this week, but I would again kindly ask you to provide some information on the above two points, when you have some time (I am putting the application back to Needs review, so you see my questions, even though I didn't push any changes yet).
Thank you again for the feedback!
Comment #16
slogar32 commentedI have now pushed the changes for points 1. and 2. from the above list, and explained number 4. in my above comment. I understand, that those were the 3 security issues that were mandatory to fix. If I need to do something on point 3 from the list, please read my above questions and point me in the right direction. Otherwise, I think this is ready for review now.
Comment #17
klausiThanks for the fixes!
kontainer.create_media: ah I see, did not see the access check later in the service. I would recommend to untangle that and do the access checking explicitly on the routing layer, then there is a lower risk that this gets lost in a refactoring for example.
Generating URLs with CSRF token: it works like this, which you can use similarliy for your ajaxTurstedUrl
Which will output /admin/reports/status/run-cron?token=QJoWTyS5Bcf8KP_gvhmjUwm-s1rlrvSqL3XHgVsxEKQ
Or do you need to CSRF token standalone for some reason? It is only every useful in combination with the path?
src/Authentication/Provider/KontainerAuth.php: hash_equals(): Caution: It is important to provide the user-supplied string as the second parameter, rather than the first. You are doing that wrong. But I think it is very hard to exploit this with a timing attack, so would consider this a security hardening and not a security blocker.
Otherwise looks good to me!
Thanks for your contribution, Domen!
I updated your account so you can opt into security advisory coverage now.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on Slack or IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #18
slogar32 commentedThank you so much for the explanations! I can say, that I learned something new and useful from this application :)
Thank you again for your time!