Adds <img> and <hr> to CustomSafePolicy, removes obsolete <tt>. <img> allows
only attributes src and alt.
Both <br> and <br /> are correct. For that, this rather uses
TagBalancingHtmlStreamEventReceiver
Thanks: Ingo Wolfmayr
Allows both <br> and <br /> to pass in UtilCodec::checkStringForHtmlSafe, both
are correct.
Clarifies owasp.properties documentation about how to create own sanitizer
policies
No functional changes, just removing a compilation warning
While compiling with Java 11 I got this message:
> Task :compileJava
UtilHttp.java:502: warning: [unchecked] unchecked call to
<R>map(Function<? super T,? extends R>) as a member of the raw type Stream
[...]
This fixes it with the help of Eclipse
When you forward a request-map on json response after a service call like this :
<request-map uri="updateMyEntity">
<security https="true" auth="true"/>
<event type="service" invoke="serviceWithUnserializableElement"/>
<response name="success" type="request" value="json"/>
<response name="error" type="request" value="json"/>
</request-map>
The request json works fine if the serviceWithUnserializableElement have an element unserializable on out put at the first level
<service name="serviceWithUnserializableElement"...>
<attribute name="outputStream" type="java.io.OutputStream" mode="OUT"/>
</service>
If the definition is like this
<service name="serviceWithUnserializableElement"...>
<attribute name="outputStreamMap" type="Map" mode="OUT"/>
</service>
The json failed to generate if the outputStream is a map. despite the function UtilHttp.getJSONAttributeMap that safe only the first map level and don't work in deep.
By the way, we improved the getJSONAttributeMap to work in deep by a recursive treatment on Map and List.
UtilProperties::setPropertyValueInMemory was only based on files. Thinking by
analogy, as Pierre pushed SystemProperties with OFBIZ-6189, I thought that by
adding an UtilProperties::setPropertyValueInMemory based on
EntityUtilProperties::getProperties it would resolve the issue. But it did not.
Looking closer at the code, I wondered why UtilProperties::setPropertyValueInMemory
was used at all.
This fixes the issue by simply removing setPropertyValueInMemory and setting "Y"
or "N" when calling testInvoicePerShipment.
It though keeps the new UtilProperties::setPropertyValueInMemory variant
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
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
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
ComparableRange is a super class of DateRange that is Serializable. So
ComparableRange needs to be Serializable Too. Same with AbstractJob for PurgeJob
and GenericServiceJob
Renames ControlServlet class to OfbizControlServlet, because it shadowed the
simple name of it superclass
It can be exceptionally confusing, create lots of situations in which you have
to look at import statements to resolve references and creates many
opportunities to accidentally define methods that do not override methods
in their superclasses.
Same for XmlRpcClient.java
At https://markmail.org/message/3mhzlqew3igad3r2 I reported an issue that I was
not able to really qualify. After exchanging with a Checkstyle expert
(see markmail thread).
I was unable to find what in our checkstyle.xml file was wrongly throwing these
warnings. I decided that there was no reason to throw those warnings.
So I decided to put the SuppressionCommentFilter in our checkstyle.xml file and
use CHECKSTYLE_OFF: ALMOST_ALL/CHECKSTYLE_ON: ALMOST_ALL around
the concerned lines as documented here
https://checkstyle.sourceforge.io/config_filters.html#SuppressionCommentFilter_Examples
Prevents an useless inevitable warning by commenting out
RequestWrapper::getParameterNames and with it all the unused methods in
RequestWrapper class
Also better comments CacheFilter::doFilter by giving its real and only goal:
<<to prevent a post-auth security issue described in OFBIZ-12332>>
This definitely solves all issues by introducing a CacheFilter and
RequestWrapper classes inspired by several works found on the Net.
Also moves the change introduced before in ContextFilter to CacheFilter.
The basic problem is that you only can use once
ServletRequest::getInputStream or the ServletRequest::getReader
Also not both, even once, ie they can be seen as same from this POV.
The integration tests all pass.
Also replace the checked String "</serializable>" by "</serializable" as, like
reported by Jie Zhu, the former could be bypassed by using "</serializable >"
Thanks: Jie Zhu for report
On the service calcShipmentCostEstimate, each estimated shipment cost is analysed to resolve which ones should be applied on the order.
During the breakQtys block analysis, OFBiz checks if the estimate match the quantity with their breaks and validates if one is good.
If a rule contains multiple break type (ex: weight and price) this will be ignored or use as partial, only one break would be analysed.
To solve it we extend the analyse on the break type combinaison.
After a global code review, we reformat the function to down less code quantity for help the reader on:
* use an Util function to resolve BigDecimal values
* dedicate function to resolve the shipping address
* dedicate function to validate a break type
* move multiple loop to stream
Thanks to Gil Portenseigne and Jacques Leroux for their look
(after discussing this on security@ofbiz.apache.org, it was decided to open a
Jira issue for that)
I've noticed that OFBiz Framework sometimes uses static initialization vectors
(IV) while creating a cipher:
https://s.apache.org/vhlbjhttps://s.apache.org/nyndk
IVs should be unique and ideally unpredictable to avoid producing the same
ciphertexts for the same plaintexts.
The issues can be fixed with something like the following:
byte[] rawIV = new byte[8];
SecureRandom random = new SecureRandom();
random.nextBytes(rawIV).
IvParameterSpec iv = new IvParameterSpec(rawIV);
jleroux: this prepends the IV in order to decrypt the plaintexts. It's similar
to what has been done for the DesCrypt class. But contrary to the DesCrypt class
I did not test.
Thanks: Artem Smotrakov
(after discussing this on security@ofbiz.apache.org, it was decided to open a
Jira issue for that)
I've noticed that OFBiz Framework sometimes uses static initialization vectors
(IV) while creating a cipher:
https://s.apache.org/vhlbjhttps://s.apache.org/nyndk
IVs should be unique and ideally unpredictable to avoid producing the same
ciphertexts for the same plaintexts.
The issues can be fixed with something like the following:
byte[] rawIV = new byte[8];
SecureRandom random = new SecureRandom();
random.nextBytes(rawIV).
IvParameterSpec iv = new IvParameterSpec(rawIV);
jleroux: we prepend the IV in order to decrypt the plaintexts. I'll do
something similar in ValueLinkApi class ASAP
Thanks: Artem Smotrakov
This prevented to run the stable demo, hence the next, weirdly the trunk had
not this problem. Anyway better safe than sorry... Maybe related to Gradle
version or rather libs loaded?
The reason why the stable (and old) demos were not running is because the
EntitySaxReaderTests did not pass
My changes in OFBIZ-12249 were only to handle textareas.
The case Nicolas reported is not related to a textarea but to the special case
of KeywordSearchBox handled by KeywordSearchBox.ftl.
So this simply bypasses this special case using the "DUMMYPAGE" key then present
I get an IndexOutOfBoundsException when using the EntityImport.
The problem occurs while having a resemblance of an url in the data.
For example
screenPath="component://... is interpreted as url because of '://'
but doesn't match a valid url pattern.
jleroux: I decided to keep it simple and to take the "component://" and the
"https://localhost" cases apart. I see no reasons to fear "https://localhost"
there. It should be only used in a safe dev env.
Thanks: Sebastian Berg and Nicolas Malin for report
When creating a plugin via gradle :
./gradlew createPlugin -PpluginId=plugin-test -PpluginResourceName=PluginTest
-PwebappName=plugin-test -PbasePermission=PLUGIN_TEST
and loading all the required data and permissions, the plugin doesn't appear
in the menu.
It comes from the ComponentConfig.java file, L1229, when the permissions gets
trimmed and modified. I tried removing it locally and it fixed the problem.
Thanks: Gaetan Chaboussie
In SafeObjectInputStream.properties
Renames listOfSafeObjectsForInputStream to allowList and fixes it
Introduces a denyList
Adapts SafeObjectInputStream class to new denyList
Removes "DiskFileItem, FileItemHeadersImpl are not serializable" case. It does
not appear in trunk.
Handling with exception Rather than returning null cleans UtilObject class.
Restrict unauthorized deserialisations to java.rmi instead of java.rmi.server
On uploading File in Ecommerce Profile's File Manager,
"The following required parameter is missing:
[IN] [uploadPartyContentFile.partyContentTypeId]" error is displaying.
Steps to regenerate the issue:
Open Ecommerce on Ofbiz.
Login with any user.
Go to Profile.
Navigate down to File Manager.
Select Purpose.
Seletct Mime Type
Click upload.
Thanks: Aishwary Shrivastava for report, Priya Sharma fir the fix