Commit Graph
28349 Commits
Author SHA1 Message Date
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
Jacques Le Roux 30770e1cea Fixed: Remote Code Execution (File Upload) Vulnerability (OFBIZ-11948)
In SecuredUpload::isValidImageFile I initially used isValidText() and thought
that decoding would be better so finally used isValidTextFile() instead. But
then valid images files are not passing. So this replaces isValidTextFile by
isValidText there.

Also while at it removes few other PHP tokens, now useless (hopefully, I have
still to check encoded and encrypted PHP webshells), from
security::deniedWebShellTokens. The less tokens we have the better the whole is
legible.
Improves related comments.

Modifies SecurityUtilTest::webShellTokensTesting accordingly
2022-02-05 10:13:44 +01:00
Jacques Le Roux 036a1fde29 Fixed: Remote Code Execution (File Upload) Vulnerability (OFBIZ-11948)
I forgot about SecurityUtilTest::webShellTokensTesting. This fixes it.

Note that I expect to simplify and remove more tokens for PHP, but I have 1st
other things to do...
2022-02-04 15:03:51 +01:00
Jacques Le Roux 5b1843f1c0 Fixed: Possible authenticated attack related to Tomcat CVE-2020-1938 (OFBIZ-12558)
Despite OFBIZ-11407, the 2 values secretRequired and especially
allowedRequestAttributesPattern are commented out because of OFBIZ-12558

The Tomcat default values will be used as recommended by
https://tomcat.apache.org/tomcat-9.0-doc/config/ajp.html#Introduction
This is in relation with
https://tomcat.apache.org/security-9.html#Fixed_in_Apache_Tomcat_9.0.31
and
https://tomcat.apache.org/tomcat-9.0-doc/security-howto.html#Connectors

Thanks: Lion Tree for report
2022-02-04 12:28:47 +01:00
Jacques Le Roux b0b02034ee Fixed: Remote Code Execution (File Upload) Vulnerability (OFBIZ-11948)
Lion Tree <liontree0110@gmail.com> has reported us that
"CVE-2020-1938 is not fully fixed".

Though it was fixed by OFBIZ-11407, it still possible for an authenticated user
to upload a webshell included in an image using one of the upload possibilities
in OFBiz. That is not new and covered by OFBIZ-12080 "Secure the uploads", but
was still incomplete.

This enforces the secured uploads by
* checking in SecuredUpload::isValidImageFile that a webshell is not embedded in
an image.
* Keeping only "<%" as a denied token for JSP webshells, instead of currently
"<%@ page"
* Adds "application/text/x-ruby" to SecuredUpload::isExecutable

Also
* Adds "<jsp", and "<?" for PHP. Even if OFBiz does not use PHP at all,
it's often installed on servers.
* Removes "import=\"java" and "runtime.getruntime().exec(". They are no
longer useful since "<%" and "<jsp" block them.
* Remove php token since I'll put "<?" in.
* Adds "#!", rather than adding other shebangs like perl,python and ruby

This will make deniedWebShellTokens more understandable.

But I'm conscious that despite SecuredUpload::isExecutableI I still need to
better handle encoded webshells. I'll do that soon in a second approach.

I'll also certainly more prune PHP related tokens.

Thanks: Lion Tree for report
2022-02-04 12:10:05 +01:00
Jacques Le Roux 6889ed1c9f Improved: no functional change, adds a BuildBot badge (INFRA-22807)
Better relies on ofbizTrunkFramework build rather than ofbizTrunkFrameworkPlugins
because the later depends on the former
2022-02-03 11:17:49 +01:00
Nicolas Malin c6e44d143f Fixed: Attribute default-field-type hidden doesn't work for auto-fields-service element (OFBIZ-12555)
Fix the compilation error on build bot that not support java11, downgrade the code to java8
2022-02-03 10:46:30 +01:00
Nicolas Malin 850a32df17 Reverted: Improved: no functional change, adds a BuildBot badge (INFRA-22807)
This reverts commit 884864b07f that contains a revert error of 9ea7afe97a
2022-02-03 10:46:10 +01:00
Jacques Le Roux 884864b07f Improved: no functional change, adds a BuildBot badge (INFRA-22807)
It works locally (once you have installed Ruby, asciidoctor and
asciidoctor-diagram). CHecking that it's also OK on BuildBot, let's see result
at https://nightlies.apache.org/ofbiz/trunk/readme/html5/
2022-02-03 09:53:55 +01:00
Nicolas Malin 9ea7afe97a Fixed: Attribute default-field-type hidden doesn't work for auto-fields-service element (OFBIZ-12555)
When you define a widget form and wish populate hidden fields with the element auto-fields-service, OFBiz rendering each as edit field type.

    <form name="ListPartyQuals" ...>
        <auto-fields-service service-name="updatePartyQual" default-field-type="hidden"/>
    </form>

The problem came from the function ModelFormFieldBuilder.induceFieldInfoFromServiceParam didn't manage the case "hidden"

By the way, this function is "if" forest, and simplify reading.
2022-02-02 18:07:37 +01:00
Jacques Le Roux 023a89e29e Fixed: View for ViewBinaryDataResource missing (OFBIZ-12552)
The view definition for ViewBinaryDataResource is missing.
Goto: /content/control/EditDataResource?dataResourceId=GZ-DIG
Click the "Download"-Button.

Thanks: Ingo Wolfmayr for the patch
2022-02-01 13:14:43 +01:00
Jacques Le Roux 418d6e03d4 Fixed: Manufacturing Jobshop find screen by default does not show all production runs (OFBIZ-12550)
The manufacturing jobshop find screen has the seach date initialized to nowdate.
if one wants to see all production runs, one has to clear the date which should
be empty initially

The same problem exists on the MRP log find where the date is filled by default.

Thanks: Hans for report and patches
2022-02-01 08:57:29 +01:00
Jacques Le Roux 9d4f29292e Fixed: [SECURITY] CVE-2022-23437: Infinite loop within Apache XercesJ xml parser (OFBIZ-12549)
Severity: high

Description:

There's a vulnerability within the Apache Xerces Java (XercesJ) XML
parser when handling specially crafted XML document payloads. This
causes, the XercesJ XML parser to wait in an infinite loop, which may
sometimes consume system resources for prolonged duration. This
vulnerability is present within XercesJ version 2.12.1 and the
previous versions.

Mitigation:

Apache XercesJ users, should migrate to version 2.12.2

Credit:

This issue was discovered by Sergey Temnikov and Ziyi Luo, from Amazon
Corretto/JDK Team

References:

https://markmail.org/message/vcmhwbuorfgcdr6l
2022-01-31 17:45:53 +01:00
Nicolas Malin d30d362aa6 Fixed: Element condition-[expr/list/object] doesn't work with compound (OFBIZ-12546)
When you create an entity-condition in a form or grid under a compound element, to write a valid xml you write it with the namespace like this :

    <wf:actions>
        <wf:entity-condition entity-name="PartyRelationship"...>
            <wf:condition-list>
                <wf:condition-expr field-name="partyIdFrom" from-field="parameters.partyIdFrom"/>
                <wf:condition-expr field-name="partyIdTo" from-field="parameters.partyIdTo"/>
            </wf:condition-list>
        </wf:entity-condition>
    </wf:actions>

This failed when OFBiz execute the search with error Invalid element with name '[wf:condition-expr]' found under a condition-list element.

The error came from the class EntityFinderUtil.ConditionList who analyze the condition-list's children with the namespace + node name instead take only the node name.

    if ("condition-expr".equals(subElement.getNodeName()))

To solve this issue we only check the local node name regardless from the namespace used.
2022-01-31 14:39:57 +01:00
Jacques Le Roux 7df68996a7 Fixed: Wrong Field Name Definition in RequirementForms (OFBIZ-12505)
The issue exists also in the older version.

The field "requirementByDate" form "FindApprovedProductRequirements" in
RequirementForms.xml has been set wrongly and it should be "requiredByDate".

This causes the result could not be queried out properly as indicated as below:

The result is governed by the service "getRequirementsForSupplier",
where reads the list from the view "RequirementAndRole".
In the view entity definition, the field is defined as
<alias entity-alias="RQ" name="requiredByDate"/>,
but it is not the case in the form "FindApprovedProductRequirements" above.

After changing it to the correct name, the bug is solved.

jleroux: Same exists in OrderEntryForms::FindRequirements

Thanks: Schumann Ye for report Pierre Smits for creating the initial PR494
2022-01-31 12:26:42 +01:00
Pierre Smits b1c0465202 Improved: List and Grid (OFBIZ-11345) (#495)
According to the definition in widget-form.xsd the use of a combination of a form with type="list" is deprecated in favour of a grid.
Refactor various list forms into grids.
Refactor various list form references in screens.

modified:
PerfReviewScreens.xml.xml: from form ref to grid ref
PerfReviewForms.xml: from form definition with list ref to grid definition with list ref, additional clean-up
2022-01-31 11:52:15 +01:00
Pierre Smits 1f3229c3f9 Improved: List and Grid (OFBIZ-11345) (#467)
According to the definition in widget-form.xsd the
use of a combination of a form with type="list" is
deprecated in favour of a grid.
Refactor various list forms into grids.
Refactor various list form references in screens.
Modified:
PersonTrainingForms.xml: from form definition with list
ref to grid definition with list ref, additional clean-up
EmployeeScreens.xml: from form ref to grid ref , additional cleanup
PersonTrainingScreens.xml: from form ref to grid ref , additional cleanup
2022-01-31 11:49:18 +01:00
Jacques Le Roux 7562476e1e Fixed: Attribute 'placeholder' is not allowed to appear in element 'text'
Completes the previous fix by Wei Zhang. This was committed at a wrong place
for OFBIZ-5341. Only text was concerned, not date-time
2022-01-29 10:56:15 +01:00
bjugl 90995f090f Fixed: Webapp Position overrides older entries. (OFBIZ-12496) (#454) 2022-01-28 10:25:11 +01:00
Pierre Smits b2dd912794 Improved: Recruitment screens updated to use Grid rather than list forms (OFBIZ-11345)
According to the definition in widget-form.xsd the
use of a combination of a form with type="list" is
deprecated in favour of a grid. Therefore refactored various
Recruitment forms to use grid and updated references from
relevant screens to forms.

Thanks: Pierre Smits for changes.
2022-01-28 07:49:01 +00:00
Daniel Watford 65dfc407cb Improved: Fix syntax error in package.json 2022-01-27 11:52:41 +00:00
Jacques Le Roux 3c1e659b5e Improved: no functional change, format package.json as done by Eclipse Json editor
Use 4 spaces indenting instead of 2, shared with std text editor
2022-01-27 11:54:34 +01:00
Daniel Watford acf0730c8d Reverted: Labels used for Customer Request Items (OFBIZ-12508) 2022-01-26 17:14:51 +00:00
Jacques Le Roux b16065c0bd Fixed: Upgrade Tomcat from 9.0.54 to 9.0.58 (OFBIZ-12539)
The fix for bug CVE-2020-9484 introduced a time of check, time of use
vulnerability that allowed a local attacker to perform actions with the
privileges of the user that the Tomcat process is using. This issue is only
exploitable when Tomcat is configured to persist sessions using the FileStore.

Note: because I'm a kind of outlaw (using deprecated Win 7) I must use node
13.14.0 and it causes me some issues, like the previous revert.
You can't have your cake and eat it
2022-01-26 13:07:50 +01:00
Jacques Le Roux 74b9146178 Fixed: Upgrade Tomcat from 9.0.54 to 9.0.58 (OFBIZ-12539)
Reverts changes in package.json accidentally committed
2022-01-26 12:52:28 +01:00
Jacques Le Roux 6ed30b7665 Fixed: Upgrade Tomcat from 9.0.54 to 9.0.58 (OFBIZ-12539)
The fix for bug CVE-2020-9484 introduced a time of check, time of use
vulnerability that allowed a local attacker to perform actions with the
privileges of the user that the Tomcat process is using. This issue is only
exploitable when Tomcat is configured to persist sessions using the FileStore.
2022-01-26 12:31:50 +01:00