Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Mar 2016 at 21:40 UTC
Updated:
5 Aug 2020 at 12:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
skaughtComment #3
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxSKAUGHT2692853git
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #4
skaughthave applied Coder and pareview.sh error.
a few conditions of pareview in .module have been skipped as they broke php.
also in .tpl -- these are now parsed before they are saved to dbase..but i can't bypass note.
Comment #5
skaughtComment #6
skaughtreset tag
Comment #7
romanblanyar commentedHello, I have installed and tested your module. When I try to ыset Section Title in the module settings get this errors:
Notice: Undefined index: skill_item in skillset_inview_form_submit() (line 534 of C:\xampp\htdocs\drupal\sites\all\modules\skillset_inview\skillset_inview.module).Warning: Invalid argument supplied for foreach() in skillset_inview_form_submit() (line 534 of C:\xampp\htdocs\drupal\sites\all\modules\skillset_inview\skillset_inview.module).Comment #8
skaughtgood catch.. i've just run through with a clean install and see you've submitted the form without first adding any 'skill'.
I've added a routine to detect empty on submit.
thanks.
Comment #9
skaughtlast error from pareview.sh:
this is passed through filter_css on skillset_inview_form_submit() [see line 555]
as are 'skill titles' on line 563 -- which this has now cleared with t() on tpl.
So i'm not sure how else to fix/bypass this an a notice.
Comment #10
skaughtComment #11
skaught#9, have address by renaming db field (from 'title' to 'name') seems as though it's just trying to protect $obj->title too vigorously due to generaic use of ->title
Comment #12
skaughtComment #13
skaughtComment #14
skaughtComment #15
skaughtComment #16
skaughtComment #17
skaughtComment #18
skaughtComment #19
skaughtComment #20
skaughtComment #21
skaughtComment #22
skaughtComment #23
th_tushar commentedHi @SKAUGHT,
I have manually reviewed the D7 version of your module,
There is a security vulnerability in your module,
$item->namein skillset_inview_add_form function of .module file should be passed through check_plain function.Would review the code again to find more such issues. Changing the status to "Needs work".
Comment #24
skaughtthose items are pulled from the database. And 'name' is pre run thru xss_filter on submit, percent is an int field (taken thro a Range field). Display in on an admin panel with module permission. Is seen on /admin/content/skillset-inview/add -- quick list for content admin to see all items while adding new.
name output will contain html, check_plain would break that output.
Comment #25
skaughtComment #26
th_tushar commentedHi @SKAUGHT,
The user entered fields should be stored as is in the database. When user edits the field, he should get what he has entered. The value should be sanitized before displaying it back to user. So, please fix the issue as per comment #23.
Comment #27
skaughtsorry, NO. that is a security break. data should always be pre filtered before stored.
that's a UX request. wont' fix.
current UX flow is: ..after uses 'saves' that is then shown in the list before. and is then clean to add another new item. a notice of new item added is given by drupal_set_message at that point.
cheers.
Comment #28
th_tushar commentedWhen handling data, the golden rule is to store exactly what the user typed. When a user edits a post they created earlier, the form should contain the same things as it did when they first submitted it. This means that conversions are performed when content is output, not when saved to the database
Thanks.
Comment #29
skaughtsorry, i will not subscribe to that 'golden rule'. that is a matter of option. i will continue to follow this other 'golden rule' thanks.
Again, as the field does contain html (as seen in the ALLOWED HTML description below the input field, We do want to make sure that it is only what is expected —— AND, that is is not broken html.
WORKS AS DESIGNED.
Comment #30
skaughtIn earnestness to #23. have wrapped $item->name with additional filter_xss()
7.x branch — commit id: dc9b30bf00b8dbde9e347233792ac79059aba525
8.x branch — commit id: 89746dc1387bb7005bfe62333ca0d697fdc245b
FIXED
Comment #31
skaught@th_tushar
Of course, thank you for your review. But I do hope you extend your own process for pre-filtering data. unfiltered data going in could include
<script>tags... SQL injections etc.Best general 'golden rule' would be it to 'take it from both ends'.
Comment #32
skaught7.x & 8.x line:
touchup resulting from #29 -- add form_error trigger to notify uses of broken HTML (did just fix without giving user chance to correct their mistake) @UX_love
d7 line — edit/order page
@a11y (as Drupal 7 lacks INLINE FORM ERRORS -- rework error notes as can best do..)
Comment #33
skaughtComment #34
skaughtadd skillbar color to 8.x line.. pic attached.
Comment #35
skaughtnicer sample colors
Comment #36
skaughtComment #37
skaughtsilly me! lost sight of farbtastic being included by core (color). have reworked 8.x to use it.
16million colors — knock yourself out!
Comment #38
skaughtComment #39
klausimanual review of the 8.x branch:
The wrong usage of t() is a blocker right now and you need to know where to apply sanitization and where not.
Comment #40
skaughtof your more direct points:
2. Unescape.php -- due to twig escaping any input that does that html being passed thru twig' t()...( and pareview, then complaining about using the old '!' placeholder) -- this twig filter was introduced to correct for final render.
3. those are procedural function calls ..I've had no warning about missing DI..so i'm not aware of what to specifically add beyond what 'is there now'. please clarify missing DI statements (pareview also doesn't note this..)
7. final block (once placed in a theme/region) is not updated after a order change, nor after color update) -- thus cache flush was added to due so.
8. document.write --> if uses browser does not have JS on...then color picker will not be there...therefore instruction to use is not needed @JS_DEGRADE_STATE @works_as_designed
10. (shorter function names) yes..a nice to have... due to porting from D7 originally and 'keeping things similar' still.
11 @works_as_designed [ i think that sample is coming from one of the validate functions}.. i'm striping input down to match for duplicate, or checking from broken html. keeping in mind i am 'allowing tags' .. and only those. i'm keeping control over that. (and ties to point 12)
12. @works_as_designed -- as from my above conversation @th_tushar -- not prefiltering data is a bad golden rule. 'take it from both ends' .. my user is made aware that they have broken html, or dis-allowed tags (: @UX @BETTER_data_handling
1.4.5,6,9 --in short order(similar points), will address shortly..
i'm just waking up and having some coffee right now.. will updated ticket status when re-work is complete. thanks!
Comment #41
klausidependency injection: every time you are using \Drupal in a class you are doing it wrong. There are some exceptions, but most of the time it is possible to pass in services that you need through the constructor. https://www.drupal.org/node/2133171 has an intro on that and you can look at many examples in core that do it.
Comment #42
skaughti do get what you mean...
a quick aside:
it's actually confusing because #2133171 actually makes it look like "it's okay to do this", and there certainly are enough code samples floating everywhere that do this..
so: it seems like i should just use
\Drupalas the comment is 'returns a Drupal\Core\Database\Connection object'the sample doesn't provide a secondary example showing this proper
usestatement.Comment #43
skaughtin progress note:
#39 point5
<q>@name</q> is a replica. !links', array('@name' => $name, '!links' => $links)));can not replace '!' with '@'
links are for @a11y related error message links (duplicate names were entered). yes, ! is not suppose to exist, but does. again, can't replace as output is then broken.
Comment #44
skaughtComment #45
skaught@klausi
have replaced db_select() and render(). Admittedly, i'm still fuzzy on DI use.. please provide any clearer samples should these changes not be enough.
as well as other points have been addressed, commit comments follow bullet points from #39.
Comment #46
skaughtComment #47
skaughtalso, i've added my 2cents against Handle text in a secure fashion this golden rule is garbage!
document is already noted as 'needing update' -- indeed it does. aim for better practice.
Comment #48
klausimanual review:
But that are not critical application blockers, otherwise RTBC.
Assiging to mpdonadio as he might have time to take a final look at this.
Comment #49
mpdonadioAre we reviewing both the D7 and D8 branches, or just the D8 one?
And, I have read the chain here. Though you may not agree with it, save as-is and sanitize on output / use DB placeholders is the Drupal way of handling things, and is a perfectly acceptable from a security standpoint. Personally, I find this much easier and less error prone than scrubbing user input.
Comment #50
skaughtthanks.
I will fix t() related notes shortly. and continue revising the DI issues as i get my head deeper into it.
Comment #51
skaught@mpdonadio
..ideally both branches. klausi did just look at 8. th_tushar reviewed 7
the 'difference' between 7 & 8 is --> 8 has both the 1)theme color picker, and 2)alpha sort functions (on order form).
basically, i wrote the 7 line first.. and just in increasing my D8 learning curve got the ideas for alpha sort and user color.. so i just haven't back-ported. (maybe as an incentive to use d8) [ Of course, otherwise a themer can do as they will with the tpl and standard theme override methods..]
Comment #52
skaughtone more thought about filtering on submits:
it's always a better practive to filter on sumbit as well. WHAT IF: someone/somehow alters your validation routine? then you end up with corrupt data.
even though this is a permission based form... i'ld rather be aggressively proactive. and in the real world: i'ld like to not be sued by a client for a lazy practice.
Comment #53
skaught#48 point4-- t() wrapped fixed.
#48 point5-- end user message confirms that 'skill name' has been deleted -- this is page title and if name 'had' html in it then it is output escaped, thus html is removed.
Comment #54
skaught#53 related image-- delete has been done confirmation message. comment added to code.

Comment #55
mpdonadioAutomated Review
Review of the 8.x-1.x branch (commit 7878c40):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
CSS rule for '.skillset-inview-wrapper: hover' is broken.
In your OO code, inject your services and avoid the \Drupal static service container. This may be the best starting point, https://docs.acquia.com/articles/drupal-8-dependency-injection
The same goes for some of the static factory methods (like Url::fromRoute); there are services for nearly all of those.
Thought you shouldn't be using it in OO code, the convention is to explicitly use the static service container as ``\Drupal` and not `Drupal`.
Convention prefer that `use` blocks are alphabetical.
In render arrays, avoid concatenating markup with strings. See if there is a better render structure, or use #prefix and #suffix.
And, in a render array, avoid rendering things and using #markup. Just stuff them into the render array w/ the right properties.
The render array in SkillsetInviewPreviewController::preview() has a dependency on the user, so you need to add this cache context. Same with SkillsetInviewZero
Doxygen convention in Drupal is to fully qualify class names.
This has been beaten to death, but the Drupal convention is to store user input as-is and handle it properly on output and via database placeholders. Under old-policy this would be consideration for a blocking issue (major API problem), but no longer is.
You are building up an lot of markup on the fly. Consider moving a lot of this to Twig templates.
TBH, there are some head-scratchers security wise. The config variables are used as-is in but have validation.
This HTML is then passed to Markup::create(), which marks the string as safe and then stuffed into a #markup render element. #markup
normally sanitizes via Xss::filterAdmin(), but this is already a safe string so it isn't sanitized. I think these are OK b/c the validation, but I still think it would be
best to handle this complex markup via Twig (Markup really shouldn't be used this way). See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21... for more info.
Why the full drupal_flush_all_caches() in the forms? Can't you just invalidate the proper render related things?
Typically, static:: is preferred over self:: (cf, PHP late static binding)
The Unescape class should not be needed w/ proper render arrays, theming, and Twig templates. You are just building up too much markup in PHP and not leveraging Drupal to do this for you.
I am not seeing any blocking issues here, but the comments above about Markup::create() and Unescape make me a little unseasy, but I don't see any exploitable vectors right now.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #56
mpdonadioThanks for your contribution, SKAUGHT!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on 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 #57
skaughtthanks!
Comment #58
skaughtreminder: new pareview testing path
http://git.drupal.org/project/skillset_inview.git
Comment #62
avpadernoI am changing status to credit the users who participated on this issue and the duplicate ones. I apologize for bumping this application.