Commit Graph
26419 Commits
Author SHA1 Message Date
Jacques Le Roux 34d68d5f6f 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

Conflicts handled by hand in data/DataEvents.java
2022-02-27 13:37:58 +01:00
Jacques Le Roux 6da27fd220 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:08:41 +01:00
Jacques Le Roux f65410ba1d 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

Conflicts handled by hand in ContentManagementServices.java
2022-02-23 12:01:04 +01:00
Jacques Le Roux 0de23fa780 Fixed: Secure the uploads (OFBIZ-12080)
Adds some tokens in security.properties::deniedWebShellTokens
Updates SecurityUtilTest::webShellTokensTesting accordingly

# Conflicts handled by hand
 framework/security/config/security.properties
 framework/security/src/test/java/org/apache/ofbiz/security/SecurityUtilTest.java
2022-02-23 12:01:04 +01:00
Jacques Le Roux d54abff8c2 Fixed: Trivial change in ProgramExport.groovy, uses the SecuredUpload import
No Functional change

Conflicts handled by hand in ProgramExport.groovy
2022-02-23 12:01:03 +01:00
Benjamin Jugl 1ed929cfc6 Fixed: Induction from DB does not represent relations properly.
(OFBIZ-12178)
2022-02-22 22:53:11 +01:00
Jacques Le Roux c638ec26f8 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:15:44 +01:00
Jacques Le Roux 50fc66c8e0 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 and move allow
all and check line length in right places (it's about content)
2022-02-20 15:43:08 +01:00
Jacques Le Roux 668e801ada 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

Manually merges SecuredUpload.java based on trunk
2022-02-19 11:37:43 +01:00
Jacques Le Roux e29e9a288a Fixed: no functional change, increase checkstyle maxErrors from 38525 to 50000
We don't care about maxerrors in 18.12. It's correctly handled in 22.01 and
that's enough. This simplify devs work and it can uselessly disturb users
2022-02-19 10:03:24 +01:00
Jacques Le Roux 4d68d1e92e Fixed: Secure the uploads (OFBIZ-12080)
Prevents billions laugh attacks
2022-02-18 15:45:43 +01:00
Jacques Le Roux 40e525aba4 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:34:03 +01:00
Jacques Le Roux cb5c385286 Improved: Create a deny list to reject webshell tokens (OFBIZ-12324)
Prevents CSV injection (MS Excel or Open Office)
2022-02-18 13:51:51 +01:00
Jacques Le Roux bc0363f12d 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 18:55:56 +01:00
Jacques Le Roux 2405ca77a5 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:28:47 +01:00
Jacques Le Roux afd3c36b5f 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 08:03:37 +01:00
Jacques Le Roux 61e8ae2f1e 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:18:31 +01:00
Jacques Le Roux d4834a0e3a Fixed: CLONE - [SECURITY] Upgrade Tika to 1.28.1 (OFBIZ-12573)
Simpler for now, later OFBIZ 12573 needs to be done
Also formatting improvement in DataResourceWorker.java: removes a blank lines

Thanks: Tim Allison <tallison@apache.org> for the nice exchanges :)
2022-02-12 11:45:06 +01:00
Jacques Le Roux 9e5fe10736 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 11:02:16 +01:00
Jacques Le Roux 43fe479e58 Fixed: no functional change, increase checkstyle maxErrors from 38515 to 38525
Anyway we don't care about 10/38525
2022-02-10 18:14:36 +01:00
Jacques Le Roux 0a25c932ac 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

Conflicts handled by hand
 framework/security/config/security.properties
 framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
 framework/security/src/test/java/org/apache/ofbiz/security/SecurityUtilTest.java
 framework/service/src/main/groovy/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy
 framework/webtools/groovyScripts/entity/ProgramExport.groovy (reverted)
2022-02-10 14:16:47 +01:00
Jacques Le Roux dcb348e5b6 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:02:53 +01:00
Jacques Le Roux 03bc88dd15 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:02:53 +01:00
Jacques Le Roux 61ddf046a5 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:02:53 +01:00
Jacques Le Roux 047849f42b 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

Conflicts handled by hand
 framework/security/config/security.properties
 framework/security/src/test/java/org/apache/ofbiz/security/SecurityUtilTest.java
2022-02-05 10:19:46 +01:00
Jacques Le Roux 9967d30caa Improved: Remote Code Execution (File Upload) Vulnerability (OFBIZ-11948)
Previous commit added one checkstyle issue to the already 39 still existing in
R18, not a big deal. This just allows checkstyle to pass (maxErrors from 38514
to 38515)
2022-02-04 14:51:19 +01:00
Jacques Le Roux 4ab4b15ade 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

Conflicts handled by hand in framework/catalina/ofbiz-component.xml
2022-02-04 12:30:34 +01:00
Jacques Le Roux e7955fc064 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:14:04 +01:00
Jacques Le Roux 77a2c747b0 Improved: no functional change, adds a BuildBot badge (INFRA-22807)
It works locally (once you have installed Ruby, asciidoctor and
asciidoctor-diagram), I see status is currently unknown, fine
2022-02-03 11:40:35 +01:00
Nicolas Malin fb95c796bb 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"
2022-02-03 11:24:56 +01:00
Jacques Le Roux 6871ef0c9c 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

Conflicts handled by hand
2022-02-01 13:25:11 +01:00
Jacques Le Roux 702fde61bb 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:58:53 +01:00
Jacques Le Roux 27a9f3fe72 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

jleroux: I already removed the "apache-" prefix but for a reason did not commit
2022-01-31 18:09:28 +01:00
Jacques Le Roux accec0efdd 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:11:51 +01:00
Jacques Le Roux c8cee7a86e 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:25:27 +01:00
Jacques Le Roux c12a801d7b 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:57:49 +01:00
Jacques Le Roux 40e89450ae 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 13:09:27 +01:00
Jacques Le Roux 243127fc92 Improved: no functional change, removes tests in GH actions
Adding testIntegration in the GH Gradle process does not work.

For a reason I'll not dig in, it ALWAYS fails at:
Cannot find service [indexProductsFromContent] location class
(org.apache.ofbiz.content.search.SearchServices)
2022-01-15 12:14:35 +01:00
Jacques Le Roux 0962230091 Improved: no functional change, add tests to GH actions
Buildbot is stale at the moment and it's better to not rely only on it.
This adds testIntegration to the GH Gradle process
2022-01-15 10:01:41 +01:00
Jacques Le Roux 5132a0653d Documented: Gradle Wrapper is not downloaded with 18.12.03 (OFBIZ-12471)
This complements previous commit:
<<After another issue reported today by Steven Payne on user ML about the
execution policy of PowerShell7, rather than using the pwsh path I document in
README.adoc solutions for cases we crossed so far.>>
with also trivial formatting.

Thanks: David S Hunter and Steven Payne for reports on user ML
2022-01-04 10:35:42 +01:00
Jacques Le Roux cb7955da16 Fixed: Gradle Wrapper is not downloaded with 18.12.03 (OFBIZ-12471)
After another issue reported today by Steven Payne on user ML about the
execution policy of PowerShell7, rather than using the pwsh path I document in
README.adoc solutions for cases we crossed so far.

Moreover I noticed today that my previous fix was not enough. "pwsh" was used
twice in the cmd line!

Thanks: David S Hunter and Steven Payne for reports on user ML
2022-01-03 18:49:41 +01:00
Nicolas Malin 49483e8a7a Fixed: Screen Xml renderer failed on renderContainer[Begin,End] ftl macro (OFBIZ-12478)
This complete the previous Improvement, Rendering different HTML container types with ScreenRenderer (OFBIZ-10495), where the xml macro are forgotten.

In same time resynchronise also missing macro renderColumn*
2022-01-03 10:23:41 +01:00
Jacques Le Roux bd95879141 Improved: updates NOTICE to 2022 2022-01-02 19:39:39 +01:00
Jacques Le Roux 0ff3ff00f1 Fixed: CheckStyleMain Task is Failing in 18.12.04 (OFBIZ-12473)
Puts back the real maxErrors value: 38514
2022-01-02 15:34:15 +01:00
Jacques Le Roux 817c596e2c Fixed: CheckStyleMain Task is Failing in 18.12.04 (OFBIZ-12473)
Because of Windows EOL difference with *nix, despite the number for maxErrors
being more around 39600+ we temporarily put 50000 here to avoid issue when
releasing. Just increasing the number of lines is the problem.

The problem was already fixed in trunk by allowing all types of EOL, ie using
NewlineAtEndOfFile value="lf_cr_crlf"
2022-01-02 10:20:11 +01:00
Jacques Le Roux b3d8434f36 Fixed: CheckStyleMain Task is Failing in 18.12.04 (OFBIZ-12473)
Because of Windows EOL difference with *nix, despite the number for maxErrors
being more around 39600+ we temporarily put 50000 here to avoid issue when
releasing. Just increasing the number of lines is the problem.
2022-01-02 10:05:49 +01:00
Jacques Le Roux 71c853fe82 Documented: no reason to have a "+" there, on same line is OK
Also to test RAT for stable again (weird it did not work last time)
release18.12.05
2022-01-01 18:24:09 +01:00
Jacques Le Roux 7809b73583 Improved: README.PDF is not generated by BuildBot nor locally (OFBIZ-12476)
This only adds pending changes for PDF files and add a link to HTML files
Also allows to test new stable RAT BuildBot build
2022-01-01 13:13:47 +01:00
Jacques Le Roux 61c28602c2 Documented: misc. trivial updates in README.adoc
Notably removes reference to SVN
Updates link to README no longer on site but on https://nightlies.apache.org/ofbiz/
2021-12-31 08:17:50 +01:00
Jacques Le Roux 90d93d5e99 Documented: just adds a sub-title about clean and add data (as in trunk)
==== Clean system and load the complete OFBiz data
2021-12-30 20:59:34 +01:00