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.
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>>
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 :/
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.
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
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
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
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
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...
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
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.
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.
When you use a callback, at this time we haven't to possibility to resolve the area target from the context like this
<wm:link target="WorkEffortAgreement/delete">
....
<wm:set-callback area-target="${useThisTarget}">
...
</wm-setcallback>
</wm:link>
* Improved: List and Grid (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.
Refactor various list forms into grids.
Refactor various list form references in screens.
Modified:
EntityForms.xml: from form definition with list ref to grid definition with list ref, additional clean-up
EntityScreens.xml: from form ref to grid ref , additional cleanup
EntitySyncForms.xml: from form definition with list ref to grid definition with list ref, additional clean-up
EntitySyncScreens.xml: from form ref to grid ref , additional cleanup
GeoManagementForms.xml: from form definition with list ref to grid definition with list ref, additional clean-up
GeoManagementScreens.xml: from form ref to grid ref , additional cleanup
ServiceForms.xml: from form definition with list ref to grid definition with list ref, additional clean-up
ServiceScreens.xml: from form ref to grid ref , additional cleanup
LogScreens.xml: from form ref to grid ref , additional cleanup
modified: ServiceScreens.xml
missed from form ref to grid ref in FindJobManagerLock
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:
- SecurityForms.xml: from form definition with list
ref to grid definition with list ref, additional clean-up
- SecurityScreens.xml: from form ref to grid ref , additional cleanup
Before sligtly modifying labels in OrderMenus.xml in PR451, here are few labels
enhancements.
Copies nl labels from CommonWorkEffort/s to WorkEffortWorkEffort/s
Removes duplicate and incomplete CommonWorkEffort/s labels in CommonUiLabels.
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:
SubscriptionScreens.xml: from form ref to grid ref , additional cleanup
SubscriptionForms.xml: from form definition with list ref to grid definition
with list ref, additional clean-up
jleroux: some modification after pushing previous commit from GH
In previous commit I noticed that Pierre used the CommonProduct label that I
committed for Pierre's "Adding som Dutch translations to common labels."
OFBIZ-6016
I did not notice then that there was already a more complete ProductProduct
label. I see no reason to create a new CommonProduct label. So I copied 2 lines
not present in ProductProduct from CommonProduct and removed the "nl" line that
is a duplicate of the "en" line.
With Michael we already said to Pierre that we don't like to review, before
pushing PR, not related changes mixed with what is announced by the title. It
complicates the review. I still remember being admonished by David E. Jones when
committing as a new committer doing the same. In the same David's spirit I see
no necessity to remove empty lines when it complicates the review...
Long story short, better make 2 different PR when such things is really
necessary...
I did not remove the <sub-hyperlink from communicationEventId lookup in
SubscriptionForms.xml. I checked there are 21 other cases like that in code.
Also better to remember to have lines not longer than 80 chars in commit comment.
All the rest is OK with me
In French, and maybe other languages, there is not only one word for new.
There are nouveau (masculine), nouvelle (féminine) and nouvel (masculine followed
by a word starting with a vowel)
Here are few related changes with existing AccountingUiLabels, HumanResUiLabel
changes and a new CommonUiLabels French labels improvements and use of
HumanResNew* labels in MainActionMenu of HumanresMenus.xml
Also alongside replaces tabs by spaces in HumanResUiLabel
Fixes random object created and used only once in classes:
SSLUtil
OrderTestServices
FinAccountHelper
GiftCertificateServices
Also related minor formatting in HashCrypt and ContextFilter
As advised by SpotBugs:
<<This code creates a java.util.Random object, uses it to generate one random
number, and then discards the Random object. This produces mediocre quality
random numbers and is inefficient. If possible, rewrite the code so that the
Random object is created once and saved, and each time a new random number is
required invoke a method on the existing Random object to obtain it.
If it is important that the generated Random numbers not be guessable, you must
not create a new Random for each random number; the values are too easily
guessable. You should strongly consider using a java.security.SecureRandom
instead (and avoid allocating a new SecureRandom for each random number needed).
Rank: Troubling (14), confidence: High
Pattern: DMI_RANDOM_USED_ONLY_ONCE
Type: DMI, Category: BAD_PRACTICE (Bad practice)>>
uses <<private static final SecureRandom SECURE_RANDOM = new SecureRandom();>>
in classes:
PaymentGatewayServices
ValueLinkApi
ContactMechServices
ProductStoreWorker
DesCrypt
HashCrypt
EntityCrypto
ContextFilter.java
Despite doing so SpotButs still reports the same error for those classes.
As it's obviously an error I prefer to not excludes those cases that will maybe
not be reported in a future version of SpotButs in Eclipse. For instance they
are not reported at all in previous version (4.5.1) but are in 4.5.2
SpotBugs reports that
<<org.apache.ofbiz.base.util.collections.FlexibleServletAccessor.equals(Object)
does not check for parameter nullity
This implementation of equals(Object) does not respect the contract defined by
java.lang.Object.equals() because it does not check the nullity of the parameter
received as argument. All equals() methods must return false when they receive
a null value.>>
This fixes it, but despite SpotBugs continues to report the same error, excludes
it.
Also removes unused expandContext private var
We don't fear collisions for "url". It's only used in testXmlRpcRequest during
a sole test, write that in exclude.xml
Also removes an unused MODULE in XmlRpcTests class
CacheSoftReference<V> extends ReferenceCleaner.Soft<V> and implements
Serializable. But ReferenceCleaner does not implement Serializable.
I see no reasons for CacheSoftReference<V> to implement Serializable. So I
simply remove that.
In ProposedOrder::calculateStartDate and TimeDuration::TimeDuration better use a
long directly (efficiency)
In ConfigXMLReader, removes unused getViewMap method
In ServiceArtifactInfo, some formatting and in writeServiceCallGraphEoModel
method add missing <<if (calledServiceSet != null) {>>
Adds and documents false positives in exclude.xml.
Remains 14 issues, I'll document them in the Jira and 'll later discuss them
on dev ML (committers attention needed). None of them are security issues :)
C:/projectsASF/Git/ofbiz-framework/plugins/rest-api/src/main/java/org/apache/ofbiz/ws/rs/listener/ApiContextListener.java:38 Ecriture d'un champ statique org.apache.ofbiz.ws.rs.listener.ApiContextListener.servletContext depuis la méthode d'une instance org.apache.ofbiz.ws.rs.listener.ApiContextListener.contextInitialized(ServletContextEvent) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java:49 org.apache.ofbiz.base.util.collections.GenericMapValues.equals(Object) checks for operand being a java.util.List [Troubling(14), High confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java:91 Déréférencement immédiat du résultat d'un readLine() dans org.apache.ofbiz.ldap.cas.OFBizCasAuthenticationHandler.login(HttpServletRequest, HttpServletResponse, Element) [Of Concern(15), Normal confidence]
C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java:49 org.apache.ofbiz.base.util.collections.GenericMapValues.equals(Object) checks for operand being a java.util.Set [Troubling(14), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRendererTest.java:875 Un appel de méthode dans new org.apache.ofbiz.widget.renderer.macro.MacroFormRendererTest$36(MacroFormRendererTest, ModelForm) passe null à un paramètre déréférencé de façon inconditionnelle dans org.apache.ofbiz.webapp.control.RequestHandler.makeLink(HttpServletRequest, HttpServletResponse, String) [Scary(8), Normal confidence]
C:/projectsASF/Git/ofbiz-framework/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRendererTest.java:848 Un appel de méthode dans new org.apache.ofbiz.widget.renderer.macro.MacroFormRendererTest$35(MacroFormRendererTest, ModelForm) passe null à un paramètre déréférencé de façon inconditionnelle dans org.apache.ofbiz.webapp.control.RequestHandler.makeLink(HttpServletRequest, HttpServletResponse, String) [Scary(8), Normal confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java:71 Ecriture d'un champ statique org.apache.ofbiz.ecommerce.janrain.JanrainHelper.apiKey depuis la méthode d'une instance new org.apache.ofbiz.ecommerce.janrain.JanrainHelper(String, String) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReportThread.java:160 Champ jamais écrit : org.apache.ofbiz.htmlreport.AbstractReportThread.report [Troubling(12), Normal confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java:72 Ecriture d'un champ statique org.apache.ofbiz.ecommerce.janrain.JanrainHelper.baseUrl depuis la méthode d'une instance new org.apache.ofbiz.ecommerce.janrain.JanrainHelper(String, String) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/CacheSoftReference.java:29 org.apache.ofbiz.base.util.cache.CacheSoftReference est Serializable mais sa super-classe ne possède pas de constructeur par défaut visible [Troubling(14), High confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/activedirectory/OFBizActiveDirectoryAuthenticationHandler.java:110 Alimentation à perte d'une variable locale dans la méthode org.apache.ofbiz.ldap.activedirectory.OFBizActiveDirectoryAuthenticationHandler.getLdapSearchResult(String, String, Element, boolean) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/openldap/OFBizLdapAuthenticationHandler.java:95 Alimentation à perte d'une variable locale dans la méthode org.apache.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler.getLdapSearchResult(String, String, Element, boolean) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleServletAccessor.java:193 org.apache.ofbiz.base.util.collections.FlexibleServletAccessor.equals(Object) checks for operand being a String [Troubling(14), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/service/src/main/java/org/apache/ofbiz/service/test/XmlRpcTests.java:47 Ecriture d'un champ statique org.apache.ofbiz.service.test.XmlRpcTests.url depuis la méthode d'une instance new org.apache.ofbiz.service.test.XmlRpcTests(String) [Of Concern(15), High confidence]
In ProductWorker::getProductFeaturesApplIncludeMarketingPackage fixes a possible
null dereferencement (tested too late)
In FileUtil::unZip uses a try-w-resource w/ ZipFile to close it. I crossed an
issue with automated OOTB formatting (clean-up on save in Eclipse). Fixed with
my external default editor (could not find where to change that in
OFBizJavaFormatter.xml
In ServiceArtifactInfo::calledServiceEcaSet fixes a possible null dereferencement
(tested too late), also minor formatting
In MacroScreenRenderer::renderScreenletSubWidget fixes a possible null
dereferencement (tested too late)
in FileUtil
Despite by best efforts in SecuredUpload::isValidFile and
PricatParseExcelHtmlThread::storePricatFile SpotBugs still reports possible null
dereferencements.
The error is NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE. It's false reports to me.
Hence excluding them in these places
In exclude.xml:
removes Confidence lines, no need to complicate things
Adds 2 DC_DOUBLECHECK false reports; synchronized is used there (maybe not the
best way but it's OK as is)
In ProductConfigWrapper::equals fixes use of == instead of equals (tested)
In UspsServices::uspsPriorityMailInternationalLabel fixes 2 possible null
dereferencements
In EntityExpr::checkRhsType fixes a possible null dereferencement