View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0030791 | mantisbt | security | public | 2022-07-22 16:14 | 2023-02-22 19:21 |
Reporter | hotzeplotz | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2.25.5 | ||||
Target Version | 2.25.6 | Fixed in Version | 2.25.6 | ||
Summary | 0030791: Allow adding relation type noopener/noreferrer to outgoing links | ||||
Description | There are a lot of security related topics around the | ||||
Steps To Reproduce | Activate | ||||
Additional Information | See: https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types scrolldown to noopener
noreferrer
| ||||
Tags | No tags attached. | ||||
Sounds like good practice indeed, but why specify both ? noreferrer implies noopener so it's redundant; I do not see in what way preventing the referer header is increasing security. I would think noopener is sufficient to cover the vulnerability. |
|
Yea, your right. Read about it, but can't remember where and can not find it right now, but the point was, that the different browser implement it differently, and so the recommendation was "use both". I am not really sure about it, but will try.
The referrer expose the super-secret-internal URL of the mantis. :-) |
|
I did some research and it seems indeed to be a browser compatibility issue. noreferrer wider support than noopener, e.g. Chrome 16 vs 49, Firefox 33 vs 52, and IE 11 partial support vs none, etc. Considering we are no longer supporting IE, and require a "recent" browser, I think it's safe to only use noopener.
I guess your use case is MantisBT on an company network, and don't want the URL to be sent to external sites, right ? |
|
PR https://github.com/mantisbt/mantisbt/pull/1834 Test script
Output |
|
@dregad not sure you are aware (I was not) that the "URL Processing" setting does not apply if "Markdown Processing" is activated. |
|
Cool, is this also covering the Is there the need to populate the new attribute[1] to parsdowns
because the attribute is not in defaults at parsedowns site [2]
Yes. Not mine but well known installations.
[1] https://github.com/mantisbt/mantisbt/blob/master/plugins/MantisCoreFormatting/core/MantisMarkdown.php#L262 |
|
The escaping of the two links in my previous looks broken? input:
does not match the intented output? |
|
No, not "populate to parsedown", the attribute is added after the block is created by Parsdown. No idea when |
|
I must have known it at some point, i.e. when I was fixing some bugs on custom MantisMarkdown class, like 5 years ago... But I forgot ;-)
Nope, based on the above and as you found out, it is not. On my dev box yesterday, I was testing with Markdown disabled.
Known, long-standing issue, see 0024628
I am not sure off-hand where the change should be made. It's been a long time since I've looked at Parsedown and it's a complex beast. |
|
So, after analysis:
It's worth mentioning that when Markdown is enabled, such URLs are always converted to links, regardless of MantisCoreFormatting URL Processing setting's value. IMO this is a bug, they should only be processed if it is ON. Tracked in 0030918. There is also inlineUrlTag(), which should be called when processing I have a work-in-progress branch on my dev box, that looks promising but needs some more testing before I can push it to the PR. It's getting late so I'll do that maybe tomorrow night. |
|
Yes, i think your right, the processing is mixing up things, what is causing the most of all the topics around Markdown.
|
|
I'm new to the source code site of Mantis and just figuring out how the things work. So there is a high probability that i may be completely wrong, but I am quite confused and the most is not totally clear to me. Sorry, for this is coming off topic, but let me share my thoughts. See it as as proposal, its just what i have learned from a naive point of view. The well known root of all evil its that the strings are processed by Parsedown and Before try to solve this, there are several cleanup tasks to solve before, to make the path clean and straightforward to follow. I think merging your PR (https://github.com/mantisbt/mantisbt/pull/1834) would be a good start, because having this function already present makes the feeling of success nicer. 1. cleanup quotings
This is related to 0022190 and https://github.com/mantisbt/mantisbt/pull/1004 (especially the last comment about emails and inline-styles). For decades the opening arrow 2. cleanup tables
Parsedown provide a helpfull method where all "marked" elements accessible. Use it. see https://github.com/mantisbt/mantisbt/compare/master...grummbeer:mantisbt:markdown-cleanup-02-tables 3. cleanup table tests
4. cleanup the blockHeader partThe Tests
The Tests todo: Clarify what a valid issue mention is.
Modify the regex to meet the mantis requirements. 5. cleanup formatting process
Parsedown provides a usefull method called After that and merging all parts together the whole part looks very nice and its a huge impact for user experience. The branches are all independent but could make it a cascading series. What do you think about? I am not experienced in contributing, so this may look strange to you, but I have no idea what the right approach is. todo
Fixing this todos would be a really nice finishing point. |
|
@hotzeplotz many thanks for your in-depth analysis. At first glance the approach seems good, unfortunately I do not have the time to have a detailed look at your proposal right now, and won't be able to, until end of August. Please bear with me, thanks for your patience and understanding. |
|
@hotzeplotz I have updated PR https://github.com/mantisbt/mantisbt/pull/1834 so the noopener/noreferrer is added as appropriate, also when using Markdown. The update fixes the issue of links being converted even when URL Processing is OFF that I mentioned in 0030791:0066845 (tracked in 0030918). As for your cleanup suggestions in 0030791:0066865, I will open a separate issue to track and discuss them independently from this (-> 0030919) |
|
very cool, damien! just delete 0030791:0066850 and 0030791:0066865, they littering the context? You implement a helper function to get the link attributes … sehr gut! |
|
It does not really matter, and it's better to leave them here now, since I have referenced these posts in 0030919 |
|
MantisBT: master-2.25 77608634 2022-07-24 06:57 Details Diff |
Allow setting rel=noopener/noreferrer for URL links $g_html_make_links now accepts 2 new contants, LINKS_NOOPENER and LINKS_NOREFERRER, allowing the admin to set the corresponding type for the URL links that are generated when the MantisCoreFormatting plugin's URL Processing is ON. The default value for $g_html_make_links has been changed from `LINKS_SAME_WINDOW` to `LINKS_SAME_WINDOW | LINKS_NOOPENER`, for security reasons. Fixes 0030791 |
Affected Issues 0030791 |
|
mod - config_defaults_inc.php | Diff File | ||
mod - core/constant_inc.php | Diff File | ||
mod - core/string_api.php | Diff File | ||
mod - docbook/Admin_Guide/en-US/config/html.xml | Diff File | ||
MantisBT: master-2.25 881f49a0 2022-08-24 09:40 Details Diff |
Set noopener/noreferrer in Markdown links URLs wrapped in angle brackets like `<http://example.com>` are not processed correctly (see FIXME note in MantisMarkdown::inlineUrlTag()). This is because MantisCoreFormattingPlugin::formatted() applies html_specialchars() first, so the < > are converted to </> and ParseDown never calls the inlineUrlTag() method, resulting in broken links on single-line strings (`<http://example.com>`). On multi-line strings, the angle brackets wrapping the link remain visible (they ought to be removed). Fixes 0030791 |
Affected Issues 0030791 |
|
mod - core/helper_api.php | Diff File | ||
mod - core/string_api.php | Diff File | ||
mod - plugins/MantisCoreFormatting/core/MantisMarkdown.php | Diff File |