-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SuiteCRM strips and mangles text e.g. in Calls #10413
Comments
At least some of the code in question was added in #6883 by @g-fantini. Can you maybe chime in? :) |
The following patch disables cleaning HTML from text fields (which is the right thing to do in my professional opinion), it does not solve removing diff --git a/data/SugarBean.php b/data/SugarBean.php
index 4f9ca9f25..d6b346f86 100755
--- a/data/SugarBean.php
+++ b/data/SugarBean.php
@@ -2522,11 +2522,6 @@ class SugarBean
if (isset($def['type']) && ($def['type'] == 'html' || $def['type'] == 'longhtml')) {
$this->$key = purify_html($this->$key);
- } elseif (
- (strpos((string) $type, 'char') !== false || strpos((string) $type, 'text') !== false || $type == 'enum') &&
- !empty($this->$key)
- ) {
- $this->$key = purify_html($this->$key);
}
}
} Shall I submit a PR? |
If you search for some of my many rants regarding the over-zealous clean-ups in SuiteCRM you can get an idea of the depths of this problem.... Just for laughs, I found this in my notes from a few years ago, when trying to work around one of these problems. This is a description of a code flow within SuiteCRM:
I know that sounds depressing, there are just too many layers in there, and some major errors were made years ago... now people are afraid to revert them. But in practice we can often solve the issues just by overriding a save function and putting back RAW values. What we should be doing is simply:
|
I feared that it may be a lot deeper, but was too hesitant to look into it (not to stare into the abyss too much). I agree on most points, except this one:
Use Prepared Statements instead :) |
Oh wow, I just found out that I (with a different account) reported the exakt same behavior back in 2017 #4446 |
I agree with the Prepared Statements, but that would be a very big change to apply everywhere in SuiteCRM code. The new v8 doesn't have any of these issues, I guess the way forward is just to progressively deprecate all of the old stuff. The new stuff naturally leads to much better practices (e.g. Symfony Doctrine) |
Hm, I'm not sure I understand you correctly. The v8 demo instance also just removes everything between |
You're right, I guess I overstated things (a lot). The technologies in v8 are better and potentially provide a cleaner architecture and better code. But there are still many bits of v7 in the code flow and so these bugs still arise. |
If the app would call |
Issue
We frequently discuss HTML and/or JavaScript issues with clients. We copy emails as text into the body of a call. I've recently upgraded to 7.14.3 (from a much older version) and I've discovered that SuiteCRM will mangle the text saved into the description of a Call (likely elsewhere as well):
<
and>
is removed, e.g. the text<script>fetch('/x')</script>
is silently removedmailto:
link is inserted in an odd way: the original text<[email protected]>
is replaced with<<a href="mailto:[email protected]">[email protected]</a>>
, which is rendered in verbatim so the mailto link cannot be clicked (screenshots below)Expected Behavior
I expect that text that I enter into the description field of a call (and everywhere else, too) is saved into the database as I entered it and it is displayed again (as text) with removing any parts.
Actual Behavior
mailto:
link (screenshots below)Possible Fix
htmlentities()
)Steps to Reproduce
Log into SuiteCRM demo instance (version 7.14.3 at the time of writing)
Edit a Call, enter the following text as the description:
Save
, then the text has changed, everything between<
and>
was silently removed and the meaning is completely different:When the call is edited again, it can be seen that this is not a display issue, but the text has been removed completely:
Edit the call again, enter the following text then click
Save
:Context
This issue makes it very hard to trust SuiteCRM to not remove/modify Data I enter into the description fields. It has modified several calls in the background, which has changed the meaning of the text completely (sample described above).
We oftentimes discuss issues with HTML and JavaScript with clients and track such issues and support requests within SuiteCRM.
Since we regularly find and exploit XSS vulnerabilities, I know quite a bit about mitigations. Removing
<
and>
before saving user-provided text into the database is not the right solution. For example, it does not help at all when user input is inserted into an HTML attribute. Instead, great care must be taken to always run the appropriate function (e.g.htmlentities()
), which SuiteCRM seems to do right already.It's just the input filter that's wrong here.
For me, this is a high-priority issue as it changes text I entered.
Please let me know if I can help in any way!
Your Environment
The text was updated successfully, but these errors were encountered: