mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
SuiteCRM strips and mangles text e.g. in Calls #5189
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#5189
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rtpt-alexanderneumann on GitHub (Apr 26, 2024).
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<foo@example.com>is replaced with<<a href="mailto:foo@example.com">foo@example.com</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
@rtpt-alexanderneumann commented on GitHub (Apr 26, 2024):
At least some of the code in question was added in https://github.com/salesagility/SuiteCRM/pull/6883 by @g-fantini. Can you maybe chime in? :)
@rtpt-alexanderneumann commented on GitHub (Apr 26, 2024):
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
scripttags yet:Shall I submit a PR?
@pgorod commented on GitHub (Apr 26, 2024):
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....
https://github.com/salesagility/SuiteCRM/pull/9127
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:
@rtpt-alexanderneumann commented on GitHub (Apr 26, 2024):
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 :)
@rtpt-alexanderneumann commented on GitHub (Apr 26, 2024):
Oh wow, I just found out that I (with a different account) reported the exakt same behavior back in 2017 https://github.com/salesagility/SuiteCRM/issues/4446
@pgorod commented on GitHub (Apr 26, 2024):
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)
@rtpt-alexanderneumann commented on GitHub (Apr 30, 2024):
Hm, I'm not sure I understand you correctly. The v8 demo instance also just removes everything between
<and>in descriptions of calls (<script>tags, email addresses).@pgorod commented on GitHub (May 1, 2024):
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.
@chris001 commented on GitHub (May 2, 2024):
If the app would call
mysqli_real_escape_stringon the the user provided text while saving into the database, and before outputting to the page, first process the text withhtmlspecialchars(), then the exact user-generated text would display on the page correctly, and this issue bug would be solved.