Commit Graph
28374 Commits
Author SHA1 Message Date
Jacques Le Roux f49bb67662 Fixed: Secure the uploads (OFBIZ-12080)
Changes name="upload_file_type_bogus" in EditCategory.ftl and
EditProductContent.ftl to name="up_load_file_type_bogus"

The last line of deniedWebShellTokens in SecuredUpload and similarly in
SecurityUtilTest classes should no have a comma and anti-slash as previous lines.

Also logs when an image contains one of the token in deniedWebShellTokens
2022-03-17 18:09:35 +01:00
Jacques Le Roux 86703f0063 Fixed: PartyScreen include-form to include-grid (OFBIZ-12591)
In OFBIZ-11345 the include-form in SecurityForm.xml has been changed to grid.
There is a reference to a form in PartyScreen that has been changed to grid.

Thanks: Ingo Wolfmayr
2022-03-17 12:23:04 +01:00
Jacques Le Roux 38bbdf151b Improved: Change common webapp to common-theme (OFBIZ-12576)
Missed these changes one month ago
2022-03-16 13:07:29 +01:00
Michael Brohl c522a7efd7 Improved: Update to log4j 2.17.2 (OFBIZ-12590)
Contains bugfixes and improvements, see
https://logging.apache.org/log4j/2.x/changes-report.html#a2.17.2
2022-03-15 16:44:27 +01:00
Michael Brohl 9991c9ec63 Improved: Update Tomcat to Version 9.0.60 (OFBIZ-12589)
For changes see https://tomcat.apache.org/tomcat-9.0-doc/changelog.html
2022-03-15 12:05:47 +01:00
Jacques Le Roux 65ae69185c Fixed: Stored XSS in webappPath parameter from content/control/EditWebSite (OFBIZ-12584)
Adds "webappPath" token in deniedWebShellTokens to definitely fix this issue

Also adds "assign" token  for possible future Freemarker exploits
2022-03-13 21:10:21 +01:00
Jacques Le Roux 33fe2aaba5 Fixed: Remove _PREVIOUS_REQUEST_ Session Attribute on non-authentication pages (OFBIZ-12047)
Demo content website cmssite/cms could not be accessed because in this case
requestUri is null. Like login request it does not need auth, I did not dig
further, here is a simple fix.
2022-03-06 09:30:30 +01:00
Jacques Le Roux 0380ab85fd Fixed: Secure the uploads (OFBIZ-12080)
Removes non satisfying last line (because images may contain those strings) in
security.properties and SecurityUtilTest.java

In SecuredUpload, renames deniedFileExtensions and deniedWebShellTokens to
respectively getDeniedFileExtensions and getDeniedWebShellTokens
2022-03-03 17:22:50 +01:00
Jacques Le Roux 9bc5f2b4d4 Improved: no functional change, simple formatting 2022-02-28 18:33:08 +01:00
Jacques Le Roux cf72d425d3 Fixed: Secure the uploads (OFBIZ-12080)
Removes <svg, replaces by onload,build according to
https://portswigger.net/web-security/cross-site-scripting/cheat-sheet
2022-02-27 21:57:38 +01:00
Jacques Le Roux d45795b916 Fixed: Stored XSS in webappPath parameter from content/control/EditWebSite (OFBIZ-12584)
Adds <<",","+",',','+'>> to deniedWebShellTokens as an obviously non satisfying
(because images may contain those strings, I checked) temporary solution before
looking at Freemarker::WhitelistMemberAccessPolicy as suggested by Matei

Thanks to Matei "Mal" Badanoiu for reporting this post-auth vulnerabily
2022-02-27 18:24:20 +01:00
Jacques Le Roux 44534438af Fixed: Secure the uploads (OFBIZ-12080)
Just occurred to my mind that I forgot to lower case the tokens in
DENIEDWEBSHELLTOKENS when checking with SecuredUpload::isValidText
2022-02-27 15:42:10 +01:00
Jacques Le Roux 2752e4e16b Fixed: Stored XSS in webappPath parameter from content/control/EditWebSite (OFBIZ-12584)
A user with rights to modify and/or create websites may insert malicious HTML
elements in the “webappPath” parameter from content/control/EditWebSite
resulting in XSS.

In order to trigger the XSS a victim needs to navigate to main page of the
modified website (eg webpos or ecommerce) and interact with the malicious
HTML elements (eg trigger the “onmouseover” event by navigating with the mouse
over the “form” and/or “a” tags).

Thanks to Matei "Mal" Badanoiu for reporting this post-auth vulnerabily
2022-02-27 13:35:48 +01:00
Jacques Le Roux fe4cefd590 Improved: Reflected XSS in content component (OFBIZ-11840)
This was already fixed but we can do better by using SecuredUpload::isValidText

Also grabs some tokens to security.properties::deniedWebShellTokens from
DataEvents.java, and adds "alert" even it's harmless as is, as it's often used
by attackers to demonstrate issues, so will earn time.

Though an improvement, I backport as it's related to security
2022-02-27 12:00:39 +01:00
Jacques Le Roux 72405ab981 Fixed: Secure the uploads (OFBIZ-12080)
Checks that the content of SecuredUpload::isValidText is not null,
else returns false

Suspenders and belt type of fix.
2022-02-25 12:06:44 +01:00
Jacques Le Roux 53dc91aa0e Fixed: Prevent post-Auth vulnerability: FreeMarker Bypass (OFBIZ-12582)
By inserting malicious content in the “Text” field from
“/content/control/updateLayoutSubContent” -> “Templates”, an attacker may
perform SSTI (Server-Side Template Injection) attacks, which can leverage
FreeMarker exposed objects to bypass restrictions and obtain RCE (Remote Code
Execution).

This fixes it by calling SecuredUpload::isValidText on the “Text” field content.
I'll check that there are no other attack opportunities...

Thanks: Mal Aware <awaremal@gmail.com> for reporting this post-auth vulnerabily
2022-02-23 11:59:41 +01:00
Jacques Le Roux 835934a9c9 Fixed: Secure the uploads (OFBIZ-12080)
Adds some tokens in security.properties::deniedWebShellTokens
Updates SecurityUtilTest::webShellTokensTesting accordingly
2022-02-23 11:59:41 +01:00
Jacques Le Roux 6cb9b12df1 Fixed: Trivial change in ProgramExport.groovy, uses the SecuredUpload import
No Functional change
2022-02-23 11:59:41 +01:00
Benjamin Jugl f3a9f05a30 Improved: Remove Whitespaces before checkboxes (OFBIZ-10461) 2022-02-22 18:58:23 +01:00
Jacques Le Roux 7eec89d523 Fixed: Secure the uploads (OFBIZ-12080)
Fixes deniedWebShellTokens tests
2022-02-21 18:01:18 +01:00
Jacques Le Roux fac2485b2e Fixed: Secure the uploads (OFBIZ-12080)
Trivial change in DataServices.java: uses the SecuredUpload import in 2 places
it was missing.

Adds some tokens in security.properties::deniedWebShellTokens
Removes a duplicated htaccess in security.properties::deniedFileExtensions
2022-02-21 17:02:12 +01:00
Jacques Le Roux 3c9cd7139a Fixed: Secure the uploads (OFBIZ-12080)
Last commits put in an issue in DataServices.java and GroovyBaseScript.groovy.
I should have used SecuredUpload::isValidFileName with dataResourceName and
SecuredUpload::isValidFile  with objectInfo. This fixes that.

Also fixes formatting checkstyle issues in SecuredUpload class.

Also fixes formatting checkstyle issues in SecuredUpload class and move allow
all and check line length in right places (it's about content)
2022-02-20 15:43:43 +01:00
Jacques Le Roux b7f1d28142 Improved: Secure the uploads (OFBIZ-12080)
Manually merges SecuredUpload.java based on 18.12, 2nd time because of previous
commit :/
2022-02-19 11:58:10 +01:00
Jacques Le Roux 04e4433b78 Improved: Secure the uploads (OFBIZ-12080)
In security.properties, adds some deniedFileExtensions and improves few comments
(easier to merge later)

In  DataServices::createFileNoPerm filters file upload to verify the filename
before the content is checked if necessary
2022-02-19 11:45:15 +01:00
Jacques Le Roux 9b497d55cb Improved: Secure the uploads (OFBIZ-12080)
Manually merges SecuredUpload.java based on 18.12
2022-02-19 11:44:32 +01:00
Jacques Le Roux 30cb6da0b1 Fixed: Secure the uploads (OFBIZ-12080)
Prevents special bytes in filename
Adds some deniedFileExtensions
2022-02-18 18:35:09 +01:00
Jacques Le Roux 3f69a54891 Fixed: Secure the uploads (OFBIZ-12080)
Prevents billions laugh attacks
2022-02-18 15:45:07 +01:00
Jacques Le Roux 9a5e1c5efc Fixed: Secure the uploads (OFBIZ-12080)
In previous comment, to prevent linked images inside SVG I used xlink:href
That's no good, it must be followed by <<="http">>, this does it. Else a lot
of SVP images would not be loadable. Because xlink:href can be used in other
cases.
2022-02-18 15:32:31 +01:00
Jacques Le Roux 54e544d302 Improved: Create a deny list to reject webshell tokens (OFBIZ-12324)
Prevents CSV injection (MS Excel or Open Office)
2022-02-18 13:50:50 +01:00
Jacques Le Roux 756b5d237e Fixed: Secure the uploads (OFBIZ-12080)
Prevents
* too long lines (10 000) by default
* linked images inside SVG

Adds a comment about double extensions not allowed
2022-02-17 19:01:05 +01:00
Jacques Le Roux 0e83f09323 Improved: Error in uploading very large files, ie >2GB (OFBIZ-11534)
I reopened, forgot that you need to set -PjvmArgs, as I commented before:
<<For a 2GB+ file you need to set Xmx to more than the double of the file size,
eg: gradlew ofbiz -PjvmArgs="-Xms1024M -Xmx5048M">>

This also adds information in security.properties:
<<By default (OOTB) OFBiz is protected against Large File Denial of Service>>
2022-02-16 17:15:24 +01:00
Jacques Le Roux 887515beef Improved: no functional change, adds a logerror in ProgramExport.groovy
For a reason I did not find, this morning I did not receive any error message in
UI when the Groovy Program content was rejected for security reason.
So I added a logerror  message to be sure something will be reported in case
this issue popup again.

BTW I switched to 22.01 branch and it was OK, then back to trunk it was OK again,
weird :/
2022-02-15 14:11:33 +01:00
Jacques Le Roux 4fa50c87b7 Improved: Create a deny list to reject webshell tokens (OFBIZ-12324)
After reviewing https://github.com/nsacyber/Mitigating-Web-Shells this mostly
adds as tokens the "Linux applications commonly used by attackers and rarely
launched by benign Apache applications"
2022-02-15 07:54:17 +01:00
Jacques Le Roux 2e0a6e4f8c Improved: Create a deny list to reject webshell tokens (OFBIZ-12324)
OK, as ever I did not commit build.gradle because I have to have it
assume-unchanged with node.js version 13.14.0, I'm an outlaw
2022-02-14 13:41:06 +01:00
Jacques Le Roux 719ca41467 Improved: Create a deny list to reject webshell tokens (OFBIZ-12324)
After reviewing https://docs.oracle.com/cd/B14099_19/web.1012/b14014/jspxml.htm,
since we use "<jsp:" this removes "scriptlet>", "declaration>" and "expression>".
They are redundant with "<jsp:"; "<jsp:" covers those already.

Also adds eval( for js and shrinks base64_decode to decode, and processbuilder
to process because of OFBIZ 12571

I always test the denied tokens against a lib of  images with 33 600 elements (
3.99 GB). If an image contains the token it can't be in the denied list.
2022-02-14 13:16:55 +01:00
Jacques Le Roux 88b5c40fdb Improved: Change common webapp to common-theme (OFBIZ-12576)
Currently the ofbiz-component.xml in themes refers to 2 webapps common-theme and
images. The location of the former is location="webapp/common". At least on my
machine this creates, or has created, a local only common directory under themes
At some points (some months ago IIRW) I had to add a bunch of .gitgnore files
unders subdirs of this local only common directory.

I think it's better to have the location of the common-theme webapp at
webapp/common-theme. Hence the possible local only common directory under themes
disappears. Backend and frontend work fine. It's just some rename so should be
easy to revert if ever I miss something.
2022-02-14 13:03:18 +01:00
Jacques Le Roux d473e3f481 Improved: no functional format change
Formatting improvement in DataResourceWorker.java: removes a blank lines
2022-02-12 11:50:09 +01:00
Jacques Le Roux 0f804b86c8 Improved: Quote "Create New Quote Term" Button URL issues (OFBIZ-12551)
Just replaces CommonWorkEfforts that no longer exists by WorkEffortWorkEfforts
2022-02-12 11:29:53 +01:00
Jacques Le Roux 9c9c175c96 Improved: EditTrackingCode screen - duplicate action trigger (OFBIZ-12569)
When accessing
https://localhost:8443/marketing/control/EditTrackingCode?trackingCodeId=9000
the action trigger "Create Tracing Code" is duplicated.

Thanks: Pierre Smits for report
2022-02-12 11:28:13 +01:00
Jacques Le Roux 8792b05c73 Fixed: CLONE - [SECURITY] Upgrade Tika to 1.28.1 (OFBIZ-12573)
Simpler for now, later OFBIZ 12573 needs to be done

Thanks: Tim Allison <tallison@apache.org> for the nice exchanges :)
2022-02-12 10:37:42 +01:00
Jacques Le Roux b52091d4b9 Documented: Continue the common-theme upload (OFBIZ-9138 Create a common theme)
Removes 2 FIXMEs about locations for image.server.path and image.management.path
properties

This follows a message I sent to the user ML
https://lists.apache.org/thread/syysbhl99h0753h77hzd5frb50foclsq
that is:
<<Actually I was wrong when I said that "a feature was lost when common-theme was
put in". The rest is right. This feature is the possibility, through
image.server.path property in catalog.properties file, to place the images, and
other the static files as well, in a location that fits with you for
any reason. Notably following the NSA recommendation to place it in "a non-web
accessible area". This to prevent webshell uploads and all kind of
other malicious files uploads. The same is true for the other property
image.management.path.

So the fact that before common-theme was put in, with the folder for images
/themes/common/images/webapp/images/, this folder was
/framework/images/webapp/images/ has nothing to do with "a non-web accessible
area". That's you to decide...

There is also a ${tenantId} var used in image.server.path property that is used
in case of multi-tenant, that's another thing.

So I finally don't think it's necessary to put the images and image.management
in runtime. This would add nothing. I'll remove the FIXMEs>>

Thanks: APL+Win to help me format the message to 80 chars in a breeze :)
2022-02-11 19:42:49 +01:00
Jacques Le Roux 8aab702d8b Fixed: Quote "Create New Quote Term" Button URL issues (OFBIZ-12551)
When I open up a quote and go to add Quote Terms, the URL of the button matches
the New Role url.

jleroux: Note and workeffort have the same issue. No need to backport, this was
due to recent Pierre Smits's "improvement".

Also removes the OrderCreateOrderQuoteNote, no longer used anywhere.
OrderAddNote was rightly used by Pierre because it's more complete (just
<value xml:lang="de-CH">Neue Anmerkung zu Offerte erstellen</value> lost,
anyway I guess <value xml:lang="de">Anmerkung hinzufügen</value> fits more

Thanks: Justine Nowak for report
2022-02-11 12:06:37 +01:00
Jacques Le Roux 28092f2a75 Fixed: Groovy denied list bypass causes post-auth RCE from webtools/control/ProgramExport (OFBIZ-12571)
The 1st issue was due to use of processbuilder token. It has been added to
deniedWebShellTokens in security.properties by f2cf262 commit for OFBIZ 11948
The tokens function (for js) and class have been added since while browsing
https://github.com/tennc/webshell

As mention the related deniedWebShellTokens TODO comment: "TODO.... to be continued
with known webshell contents... a complete allow list is impossible anyway...

So, later a deeper review of Groovy sandbox possibilities will be done..

Thanks: Y4er for report
2022-02-11 10:52:43 +01:00
Jacques Le Roux 97b3627341 Improved: no functional changes, removes trailing spaces just to pass checkstyle
Check passed locally but not on GH nor BuildBot
2022-02-10 18:27:07 +01:00
Jacques Le Roux 1878e99a7b Improved: Possible authenticated attack related to Tomcat CVE-2020-1938 (OFBIZ-12558)
Change a bit the documentation while workin on
https://cwiki.apache.org/confluence/display/OFBIZ/Keeping+OFBiz+secure wiki page
2022-02-10 17:21:22 +01:00
Jacques Le Roux f2cf262cf5 Fixed: Remote Code Execution (File Upload) Vulnerability (OFBIZ-11948)
This fixes and improves file upload.

Refactor a bit SecuredUpload class and fixes:
Prevent double extensions
Check extensions
Improves getMimeTypeFromFileName() by checking is file exists
In isValidImageFile() finally use isValidText() bypassing encoding

Completely refactor deniedWebShellTokens in security.properties by re-adding
removed tokens in last commit and adding several new ones. I have still to check
encoded, encrypted and obfuscated webshells)
Modifies SecurityUtilTest::webShellTokensTesting accordingly
While at it better format commonsImagingSupportedFormats, deniedFileExtensions
and imagejSupportedFormats properties for legibility.

Check if createAnonFile service is used in GroovyBaseScript.groovy and if a
complete file name is used (file exist) check, using SecuredUpload, extensions
and prevent double extensions, actually check all the file and stop there.

Adds some "Check if a webshell is not uploaded" comments in
ContentManagementServices.java
DataServices.java
ScaleImage.java
FrameImage.java
ImageManagementServices.java
ProductServices.java
HttpRequestFileUpload.java
ProgramExport.groovy

Trivial comments fixes in catalog.properties

Also fixes OFBIZ 12571 (I use here a space because of pending INFRA 22843)
by simply adding processbuilder to deniedWebShellTokens
2022-02-10 14:17:34 +01:00
Jacques Le Roux ff5e473109 Improved: Possible authenticated attack related to Tomcat CVE-2020-1938 (OFBIZ-12558)
As reported by Michael, secretRequired value must be false because secret value
is empty. Else a notifying message appears in log saying that AJP is not available.

This uncomment out secretRequired, so its value is now false, and document more
notably about that. I'll later add more information in the
https://cwiki.apache.org/confluence/display/OFBIZ/Keeping+OFBiz+secure wiki page

Thanks: Michael for report
2022-02-10 14:17:34 +01:00
Jacques Le Roux 03359240f9 Improved: no functional trivial cleaning changes
Removes useless menu-name="secondary" for common-theme webapp
Removes now useless runtime/patches directory. It was only used with Ant
2022-02-10 14:17:34 +01:00
Jacques Le Roux aa1547314b Documented: Possible authenticated attack related to Tomcat CVE-2020-1938 (OFBIZ-12558)
Explains that the current AJP config works only for localhost
2022-02-10 14:17:33 +01:00
Pierre Smits 8c5100d83b Improved: Dutch labels (OFBIZ-10363)
WorkEffortUiLabels.xml
2022-02-07 14:14:36 +01:00