Commit Graph
26449 Commits
Author SHA1 Message Date
Jacques Le Roux 1663da5a4a Tested: GH Actions and Buildbot Builders are not consistent (OFBIZ-23076)
This is just a try Infra asked about. I have also asked montastic if we can
have 3 different badges. For now I simply backport this one in order to test
all the Buildbot flows.
2022-04-22 12:04:33 +02:00
Jacques Le Roux 1ced939556 Improved: Prevent possible DOS attack done using Java deserialisation (OFBIZ-12592)
In previous commit I used Gradle application plugin and removed the
jvmArguments var used below in build.gradle. This restores jvmArguments, fixes
a problem with mainClassName missing in application plugin, simplifies
applicationDefaultJvmArgs and move ext.ofbizMainClass to a more logical place
2022-04-21 12:02:47 +02:00
Jacques Le Roux b7b2d1fd6f Improved: Prevent possible DOS attack done using Java deserialisation (OFBIZ-12592)
The previous commit was twice wrong:
1. System properties in gradle.properties are not defined using -D but using
systemProp.
2. Anyway systemProp. is defining system properties only available in JVM where
Gradle is running, not the application you run. For that you need to use
applicationDefaultJvmArgs in application in the main build.gradle.

Here is the system property for jdk.serialFilter

Conflicts handled by hand in build.gradle
2022-04-21 06:08:12 +02:00
Jacques Le Roux 5cc45e8701 Fixed: XML Import fails due to security check (OFBIZ-12602)
When importing an entity with "${" in for at least an element it's rejected
because of the security check done to protect from Freemarker unauth attacks
(see OFBIZ-12594).

As suggested by Ingo, allowing users with appropriate permissions seems an
usable solution. We still need to define the "appropriate permissions".
We can start with OFBTOOLS and WEBTOOLS, as it's reported by Ingo, and add
others later if they ever come.

Thanks: Ingo Wolfmayr for report and suggestion
2022-04-20 14:10:49 +02:00
Jacques Le Roux 63ecc059ec Improved: GH Actions and Buildbot Builders are not consistent (INFRA-23076)
Reverts previous commit,
see https://lists.apache.org/thread/80wzf4kclfk5nh2fss56jd6otf7y4n2f
2022-04-18 09:32:48 +02:00
Jacques Le Roux ce84fdb3ca Improved: GH Actions and Buildbot Builders are not consistent (INFRA-23076)
It's now 2 weeks that INFRA-23076 is open, so like 3 weeks that BuildBot is not
working for OFBiz at all.

So far I did not run the integration tests on GH because
* we have it on BuildBot
* it's complicated to show the results

Hopefully BuildBot will soon run the OFBiz builds again. But it does not hurt
to run the integration tests on GH, even w/o the results, because at least it's
easier than running them for each commit locally (takes time) and we can run
them locally once we know there is a problem demonstrated with GH actions.
2022-04-18 09:09:30 +02:00
Giulio Speri c0511d01cb Fixed: ecomm. listing ProductFacility out of stock issue (OFBIZ-12359)
In method filterOutOfStockProducts added case for "virtual" products.
In case a product isVirtual (= Y), then the available inventory count
(lastInventoryCount) is summed up on all its product variants, across
all the ProductFacility records, and then used to determine if the
(parent/virtual) product is in stock or out of stock.

This fix does not check if the facilityId of the ProductFacility
records retrieved is associated and enabled to the ProductStore.

Thanks Nicola Mazzoni for helping in anlyzing this issue.
2022-04-17 23:07:50 +02:00
Jacopo Cappellato ff92c4bc9c Improved: In UtilHttp, for regex processing of urls, replace Java regex with Google RE2J. (#513)
The Main advantage of RE2J is that it guarantees linear time execution.
2022-04-14 07:29:06 +02:00
Jacques Le Roux 16ed130367 Fixed: Test run was unsuccessful because of failing solr tests (OFBIZ-12595)
The previous commit for OFBIZ-12594 was only working on Windows. On *nix OSs
there is no way to reliably get "--test" String from java.class.path property.

Also the previous fix was brittle because relying only on 1 space separating
words.

This fix puts in the SolrDispatchFilter system property at the beginning of the
4 Solr tests and removes it at end of them. That presence can reliably be tested
in ControlFilter that is called before SolrDispatchFilter. It allows to bypass
SecurityUtil::containsFreemarkerInterpolation that would else change the
parameters content type that must be application/x-www-form-urlencoded.
content

Thanks: Tom Pietsch for report and Mart Naum for confirmation

Conflicts handled by hand
2022-04-13 15:00:58 +02:00
Giulio Speri 6789011488 Fixed: inv. reservation places order if not enough qty (OFBIZ-12455)
If quantity not reserved is not 0, requireInventory is set to Y, system
let an order to be placed anyway.

The usage of the service around the project let make an important
assertion: we can consider that also reserveInventory flag of the
ProductStore is Y, since right now is always the caller context that
checks for the reserveInventory flag.

This fix simply returns a specific error to the caller, avoiding the
system to place the order.

Thanks Nicola Mazzoni for helping in debug this issue and Jacopo
Cappellato for the patch review.
2022-04-07 23:40:07 +02:00
Jacques Le Roux bb59eb95b1 Tested: INFRA-23076 2022-04-06 15:16:20 +02:00
Jacques Le Roux 871ce2aa2e Fixed: Prevent Freemarker interpolation in fields (OFBIZ-12594)
I did not catch an issue put in by this feature because BuildBot is not running
for few days (see INFRA-23076) and i don't always run tests locally (relying on
BuildBot and GH actions don't run tests).

This is the error Solr tests throw else:
<<Unfortunately, the stream was empty / not available. This may be caused by
another servlet filter calling ServletRequest.getParameter*() before
SolrDispatchFilter>>

Conflicts handled by hand
2022-04-06 13:25:56 +02:00
Jacques Le Roux b24dcff344 Fixed: Prevent Freemarker interpolation in fields (OFBIZ-12594)
I did not catch an issue put in by this feature because BuildBot is not running
for few days (see INFRA-23076) and i don't always run tests locally (relying on
BuildBot and GH actions don't run tests).

This is the error Solr tests throw else:
<<Unfortunately, the stream was empty / not available. This may be caused by
another servlet filter calling ServletRequest.getParameter*() before
SolrDispatchFilter>>

Conflicts handled by hand
2022-04-06 11:28:43 +02:00
Giulio Speri 9a6b54af2e Fixed: multiple facility inventory reservation issue (OFBIZ-12264)
The ProductStore is set up to reserve inventory from more than one
facility, so the flag oneInventoryFacility is set to N.
Flags requireInventory and reserveInventory are both to Y.
Flag allocateInventory is N.

A product can be anyway reserved in a ProductStoreFacility with its
thru date set and past, so is disabled, and if is not present enough
inventory quantity on other facilities.

Added filtering by date on multiple facility code in
reserveStoreInventoryMethod() and on isStoreInventoryAvailable().
This is the first part of the problem resolution; the second part is
accomplished by path to OFBIZ-12455 Jira.

Thanks: Jacques Le Roux and Pierre SMith for Jira feedbacks, Nicola
Mazzoni for helping in bug analaysis and Jacopo Cappellato for path
review.
2022-04-05 23:10:46 +02:00
Jacques Le Roux 3797e60375 Improved: Prevent Freemarker interpolation in fields (OFBIZ-12594)
OFBIZ_12587 is a definitive solution to prevent any kind of Freemarker exploits.
But it's hard to realise because OFBiz exposes objects, like attributes from the
Servlet scopes. So in the meantime preventing Freemarker interpolation in fields
is a pragmatic solution.

This is an improvement but needs to be backported because it kinda affects
security

Conflicts handled by hand
  SeoContextFilter.java
  ControlFilter.java

When I worked with Mathieu I did not measure how it will be hard sometimes to
backport later :/

Also due to checkstyle module to MODULE change is always a pain in the ass :/
2022-04-04 09:32:34 +02:00
Jacques Le Roux 843b1c7e71 Improved: Prevent Freemarker interpolation in fields (OFBIZ-12594)
OFBIZ_12587 is a definitive solution to prevent any kind of Freemarker exploits.
But it's hard to realise because OFBiz exposes objects, like attributes from the
Servlet scopes. So in the meantime preventing Freemarker interpolation in fields
is a pragmatic solution.

This is an improvement but needs to be backported because it kinda affects
security

Conflicts handled by hand
  SeoContextFilter.java
  ControlFilter.java

When I worked with Mathieu I did not measure how it will be hard sometimes to
backport later :/
2022-04-04 09:15:47 +02:00
Jacques Le Roux 56478e4420 Implemented: Restart the ofbiz-vm3 demos server (OFBIZ-22722)
For the next demo to work we need to set the host-headers-allowed to
demo-next.ofbiz.apache.org instead of demo-old.ofbiz.apache.org

Thanks to Drew Foulks for handling the Infra part for us
2022-03-28 18:48:19 +02:00
Jacques Le Roux 3df59b5e6d Improved: Prevent possible DOS attack done using Java deserialisation (OFBIZ-12592)
Qing Xu, a security reporter, alerted us that, despite no current vulnerability,
it could be maybe possible to do DOS attacks using Java deserialisation.

That has been fixed with https://openjdk.java.net/jeps/290 and even implemented
in Java 8, but it needs a little effort on our side, here it is.

There is no real bug, to this is an improvement but a security improvement so it
will be backported

Thanks: Qing Xu for report

Conflicts handled by hand gradle.properties
2022-03-28 12:38:57 +02:00
Michael Brohl 630258751d 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

This introduces the exclusion of some compile
dependencies (bountycastle bc*-jed14) for the
itext library which interfered with newer
versions from another dependency.
2022-03-23 18:34:57 +01:00
Jacques Le Roux 5e76565b04 Documented: Date picker not initialised in ajax-called form (OFBIZ-12097)
Just adds the missing Jira issue number
2022-03-20 12:01:29 +01:00
Jacques Le Roux c4bd082359 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:11:37 +01:00
Michael Brohl 6cf0c732c1 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:26:55 +01:00
Jacques Le Roux 7482dc6966 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:11:30 +01:00
Jacques Le Roux fd71686e6a 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-06 09:42:41 +01:00
Jacques Le Roux 71adde61b5 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:18:59 +01:00
Jacques Le Roux d89e8e2789 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 22:07:42 +01:00
Jacques Le Roux 3eea7d967d Fixed: Stored XSS in webappPath parameter from content/control/EditWebSite (OFBIZ-12584)
Fixes compiles issues put in with last commit
2022-02-27 22:07:18 +01:00
Jacques Le Roux 06006f1666 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:27:49 +01:00
Jacques Le Roux f289a80749 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:43:17 +01:00
Jacques Le Roux 247b8713ba 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

Conflicts handled by hand in EntityAutoEngine.java
2022-02-27 13:39:09 +01:00
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