Commit Graph
10122 Commits
Author SHA1 Message Date
Jacques Le Roux e0f0d5271a Fixed: Prevent Host Header Injection (CVE-2019-12425)
(OFBIZ-11583)
2020-04-04 19:32:02 +02:00
Jacques Le Roux 645d419574 Merge branch 'trunk' into POC-for-CSRF-Token-OFBIZ-11306 2020-04-04 17:52:06 +02:00
Jacques Le Roux 768353a093 Improved:
Implemented:
Documented:
Completed:
Reverted:
Fixed:

(OFBIZ-)
Explanation
Thanks:
2020-04-04 15:49:49 +02:00
Jacques Le Roux c9d516d367 Fixed: The createTaskContent request does not work
(OFBIZ-11246)

It seems that same request can not be parsed multiple times if it has multi part
object in it as the parse method remove it after that.

Found one stackoverflow link around the same:

https://stackoverflow.com/questions/13881272/
servletfileuploadparserequestrequest-returns-an-empty-list

I believe that all places/uploads using this workflow should resulting the same
issue.

One possible solution I could think of without going with new approach is to set
list of file Items into the request attribute and use it if parse method remove
it and unable to retrieve on 2nd call.

Thanks: Ankush Upadhyay for the analysis and initial patch. I only slightly
modified it.
2020-04-04 15:49:43 +02:00
Jacques Le Roux e666c65b7c Improved: Improve Web Content Caching
(OFBIZ-11477)

According to OWASP OFBiz Web Content Caching is weak:

Independently of the cache policy defined by the web application, if caching web
application contents is allowed, the session IDs must never be cached, so it is
highly recommended to use the Cache-Control: no-cache="Set-Cookie, Set-Cookie2"
directive, to allow web clients to cache everything except the session ID

I though noticed that Set-Cookie2 is deprecated for a long time now. And we new
browsers policies it to often updated. So no need to use Set-Cookie2.
2020-04-04 15:49:43 +02:00
Pawan Verma 4d2e5d3e26 Fixed: Specified key was too long; max key length is 767 bytes for ProductPromoCodeEmail entity.(OFBIZ-5426) (#44)
* Fixed: Specified key was too long; max key length is 767 bytes for ProductPromoCodeEmail entity.
(OFBIZ-5426)

The problem is in the entity model. An email address should not be used in the primary key - mainly because an email address is case-insensitive. A better design would be to use the email address contact mechanism ID in the primary key.

Done Following:
1. Changed Entity Name from ProductPromoCodeEmail to ProductPromoCodeContMech
2. Related Changes for the entity name change
3. Migration service to migrate old data

Thanks, Leon for the report and Adrian Crum, Jacques Le Roux, Ingo Wolfmayr, Deepak Dixit, Pierre Smits and Gil Portenseigne for the discussion and review.

* Improved: Added new line in service definition file and lincence in MigrationServices file.
(OFBIZ-5426)

Thanks, Jacopo for the review.
2020-04-04 15:49:41 +02:00
Jacques Le Roux 43f46399ff Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes check style errors
2020-04-04 15:49:41 +02:00
Jacques Le Roux c68d43efa2 Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes an issue due to Eclipse automated import organisation.

There are still check style errors
2020-04-04 15:49:41 +02:00
Jacques Le Roux d1ca68c166 Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes a check issue (line too long)

Notice: on Windows I get 20 errors when compiling:
> Task :compileTestJava FAILED
C:\projectsASF\Git\ofbiz-framework\framework\widget\src\test\java\org\apache\
ofbiz\widget\renderer\macro\MacroFormRendererTest.java:134:
error: annotation type not applicable to this kind of declaration
        @Mock
        ^
I guess the change in build.gradle are not enough for Windows, to be seen later...
2020-04-04 15:49:41 +02:00
Daniel Watford 1fbf6c3d6b Improved: Added license header to MacroFormRendererTest
(OFBIZ-4035)
2020-04-04 15:49:41 +02:00
Daniel Watford 87277ab992 Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)
2020-04-04 15:49:40 +02:00
Jacques Le Roux 11c75b6661 Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

Fixes a typo
2020-04-04 15:49:40 +02:00
Jacques Le Roux 866c742e8f Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

It's better to allow users to change from strict to lax, at least for all
cookies. Some could want to change it by cookie type. I let the exercise for
them :)
See:https://blog.mozilla.org/security/2018/04/24/same-site-cookies-in-firefox-60
2020-04-04 15:49:40 +02:00
Jacques Le Roux 6c49411ee7 Improved: "auth" should be true for all the request url used for Application
components

(OFBIZ-4956)

Currently there are some URLs present in application components with
auth="false". So anyone can hit these URLs and access these resources without
authorization.
I think all the URLs should be secure with auth="true"

jleroux: I have also fixed the dataResourceId="GZ-DIG"

Thanks: Amardeep Singh Jhajj for report and initial fix
2020-04-04 15:25:51 +02:00
Jacques Le Roux 019b58859e Improved: POC for CSRF Token
(OFBIZ-11306)

There is no need to change it there because, apart the ecommerce application,
there are no applications that requires an anonymous flow.
It should be only changed in ecommerce controller.
2020-03-27 14:42:40 +01:00
Jacques Le Roux f4acda5ade Fixed: The createTaskContent request does not work
(OFBIZ-11246)

It seems that same request can not be parsed multiple times if it has multi part
object in it as the parse method remove it after that.

Found one stackoverflow link around the same:

https://stackoverflow.com/questions/13881272/
servletfileuploadparserequestrequest-returns-an-empty-list

I believe that all places/uploads using this workflow should resulting the same
issue.

One possible solution I could think of without going with new approach is to set
list of file Items into the request attribute and use it if parse method remove
it and unable to retrieve on 2nd call.

Thanks: Ankush Upadhyay for the analysis and initial patch. I only slightly
modified it.
2020-03-27 10:55:59 +01:00
Jacques Le Roux 2bb1de22cc Improved: Improve Web Content Caching
(OFBIZ-11477)

According to OWASP OFBiz Web Content Caching is weak:

Independently of the cache policy defined by the web application, if caching web
application contents is allowed, the session IDs must never be cached, so it is
highly recommended to use the Cache-Control: no-cache="Set-Cookie, Set-Cookie2"
directive, to allow web clients to cache everything except the session ID

I though noticed that Set-Cookie2 is deprecated for a long time now. And we new
browsers policies it to often updated. So no need to use Set-Cookie2.
2020-03-27 10:05:37 +01:00
Jacques Le Roux ef8546bf19 Improved: POC for CSRF Token
(OFBIZ-11306)

There is no need to change it there because, apart the ecommerce application,
there are no applications that requires an anonymous flow.
It should be only changed in ecommerce controller.
2020-03-23 15:30:40 +01:00
Pawan Verma 91673f1b41 Fixed: Specified key was too long; max key length is 767 bytes for ProductPromoCodeEmail entity.(OFBIZ-5426) (#44)
* Fixed: Specified key was too long; max key length is 767 bytes for ProductPromoCodeEmail entity.
(OFBIZ-5426)

The problem is in the entity model. An email address should not be used in the primary key - mainly because an email address is case-insensitive. A better design would be to use the email address contact mechanism ID in the primary key.

Done Following:
1. Changed Entity Name from ProductPromoCodeEmail to ProductPromoCodeContMech
2. Related Changes for the entity name change
3. Migration service to migrate old data

Thanks, Leon for the report and Adrian Crum, Jacques Le Roux, Ingo Wolfmayr, Deepak Dixit, Pierre Smits and Gil Portenseigne for the discussion and review.

* Improved: Added new line in service definition file and lincence in MigrationServices file.
(OFBIZ-5426)

Thanks, Jacopo for the review.
2020-03-23 17:08:58 +05:30
Jacques Le Roux 1348f9d3be Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes check style errors
2020-03-21 23:09:05 +01:00
Jacques Le Roux 28e961c062 Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes an issue due to Eclipse automated import organisation.

There are still check style errors
2020-03-21 23:01:36 +01:00
Jacques Le Roux 322df2750c Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes a check issue (line too long)

Notice: on Windows I get 20 errors when compiling:
> Task :compileTestJava FAILED
C:\projectsASF\Git\ofbiz-framework\framework\widget\src\test\java\org\apache\
ofbiz\widget\renderer\macro\MacroFormRendererTest.java:134:
error: annotation type not applicable to this kind of declaration
        @Mock
        ^
I guess the change in build.gradle are not enough for Windows, to be seen later...
2020-03-21 22:08:00 +01:00
Daniel Watford e2142dd00e Improved: Added license header to MacroFormRendererTest
(OFBIZ-4035)
2020-03-21 20:02:59 +01:00
Daniel Watford 05d734206a Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)
2020-03-21 20:02:59 +01:00
Jacques Le Roux c2fb314a1b Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

Fixes a typo
2020-03-21 12:02:03 +01:00
Jacques Le Roux fd1e7f477b Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

It's better to allow users to change from strict to lax, at least for all
cookies. Some could want to change it by cookie type. I let the exercise for
them :)
See:https://blog.mozilla.org/security/2018/04/24/same-site-cookies-in-firefox-60
2020-03-21 11:55:53 +01:00
Jacques Le Roux 3a5a657604 Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

Forgot to add UtilHttp::SameSiteFilter
2020-03-21 11:31:56 +01:00
Jacques Le Roux 7240b2642b Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

As reported by OWASP ZAP:
A cookie has been set without the SameSite attribute, which means that the
cookie can be sent as a result of a 'cross-site' request. The SameSite attribute
is an effective counter measure to cross-site request forgery, cross-site script
inclusion, and timing attacks.

The solution was not obvious in OFBiz for 2 reasons:

1. There is no HttpServletResponse::setHeader. So we need to use a filter
  (SameSiteFilter) and even that is not enough because of 2:
2. To prevent session fixation we force Tomcat to generates a new jsessionId,
ultimately put in cookie, in LoginWorker::login. So we need to add a call to
SameSiteFilter::addSameSiteCookieAttribute in
UtilHttp::setResponseBrowserDefaultSecurityHeaders.
2020-03-21 11:31:56 +01:00
Nicolas Malin d65b01148e Fixed: Unable to view entity row record in webtools if PK contains timestamp field
(OFBIZ-11426)

This problem came from when the GenericEntity try to store fields value on the map,
If the java type didn't match with the current value type, the function failed and
didn't try to convert it on the wanted type.

Thanks to Pawan Verma and Pierre Smits to raise this issue
2020-03-21 11:31:55 +01:00
Daniel Watford a769aaf5fd Improved: Ensure MacroFormRenderer uses
ModelFormField#getCurrentContainerId rather than
ModelFormField#getIdName to ensure any FlexibleStringExpander expression
defined in the field's id-name property is processed before rendering
into the container FTL macro.

(OFBIZ-4035)
2020-03-21 11:31:55 +01:00
Michael Brohl 89333dfdd8 Fixed: Fixed a bug introduced with the removal of the login security
question.

(OFBIZ-11244)

Thanks Olivier Heintz for reporting and Wiebke Pätzold for providing the
patch.
2020-03-21 11:31:54 +01:00
Dennis Balkir 54a429e8cc Implemented: _WARNING_MESSAGE_
(OFBIZ-10587)

Added warning message as a message type, by adding it in the
messages.ftl and the request-handler

Thanks to Niklas Fallik for reporting
2020-03-21 11:31:54 +01:00
Michael Brohl d3907529c3 Implemented: Remove the user login security question.
(OFBIZ-11244)

Thanks Wiebke Pätzold for providing the patch.
2020-03-21 11:31:47 +01:00
Jacques Le Roux 0da38998a9 Improved: Remove unused ‘UtilHttp#checkURLforSpiders’
(OFBIZ-11138)

The "link.remove_lsessionid.user_agent_list" properties was forgotten
2020-03-21 11:31:47 +01:00
Nicolas Malin 7f10602654 Improved: Convert CommonServices.xml from mini lang to groovy
(OFBIZ-11402)

Thanks to Wiebke Pätzold for providing the patch
2020-03-21 11:31:47 +01:00
Michael Brohl e586da62c5 Improved: Upgrade Freemarker from 2.3.29 to 2.3.30.
(OFBIZ-11445)
2020-03-21 11:31:46 +01:00
Nicolas Malin 793cf207a0 Fixed: Refactoring permission model call, alone permission service failed
(OFBIZ-11440)

During refactoring (OFBIZ-7113), the service reader used two different methods to read a
permission service definition if is present alone or in a group. For the alone version a link
was missing between the service and the permission service to resolve correctly the permission.

To solve this problem I reorganized to use only one method to initialize a service model permission.

Other point, an attribute renaming was missed : action -> permissionMainAction, when service permission call was called

Last, these problems weren't detected before due to missing unit test on failure service permission, now cover.
2020-03-21 11:31:44 +01:00
Daniel Watford 09b42258d9 Fixed: Fixed line lengths in ModelFormFieldTest to adhere to coding standards
(OFBIZ-11418)
2020-03-21 11:31:42 +01:00
Daniel Watford 59f65f3567 Documented: Documented use of field attribute parameter-name and
lookup field attribute target-parameter in widget-form.xsd

(OFBIZ-11418)
2020-03-21 11:31:42 +01:00
Daniel Watford b770f91a97 Improved: Use FlexibleStringExpander in form widget lookup field field
target parameters

(OFBIZ-11418)

Changed target-parameter attribute of the form widget's Lookup field to
use the FlexibleStringExpander type rather than String. This has been
done to allow reference to other form fields which may have had their
parameter-name attribute set to a FlexibleStringExpander expression.
2020-03-21 11:31:42 +01:00
Suraj Khurana c45ed251c1 Improved: Defects reported by code analysis tool.
(OFBIZ-10571)

Following refactoring done -
-- Refactored code to fall in line with some java standards.
-- Based on FindBugs suggestion, refactored some classes to have static nested classes instead of inner class.

Thanks Girish Vasmatkar for reporting the issue and providing the patch.
2020-03-21 11:31:41 +01:00
Jacques Le Roux 7d95c46b83 Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

Forgot to add UtilHttp::SameSiteFilter
2020-03-20 18:04:31 +01:00
Jacques Le Roux 369d5f6c95 Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

As reported by OWASP ZAP:
A cookie has been set without the SameSite attribute, which means that the
cookie can be sent as a result of a 'cross-site' request. The SameSite attribute
is an effective counter measure to cross-site request forgery, cross-site script
inclusion, and timing attacks.

The solution was not obvious in OFBiz for 2 reasons:

1. There is no HttpServletResponse::setHeader. So we need to use a filter
  (SameSiteFilter) and even that is not enough because of 2:
2. To prevent session fixation we force Tomcat to generates a new jsessionId,
ultimately put in cookie, in LoginWorker::login. So we need to add a call to
SameSiteFilter::addSameSiteCookieAttribute in
UtilHttp::setResponseBrowserDefaultSecurityHeaders.
2020-03-20 17:50:17 +01:00
Nicolas Malin 13ee4cc263 Fixed: Unable to view entity row record in webtools if PK contains timestamp field
(OFBIZ-11426)

This problem came from when the GenericEntity try to store fields value on the map,
If the java type didn't match with the current value type, the function failed and
didn't try to convert it on the wanted type.

Thanks to Pawan Verma and Pierre Smits to raise this issue
2020-03-19 14:44:07 +01:00
Daniel Watford 584f1edda5 Improved: Ensure MacroFormRenderer uses
ModelFormField#getCurrentContainerId rather than
ModelFormField#getIdName to ensure any FlexibleStringExpander expression
defined in the field's id-name property is processed before rendering
into the container FTL macro.

(OFBIZ-4035)
2020-03-19 09:51:06 +01:00
Michael Brohl 83b8b27b58 Fixed: Fixed a bug introduced with the removal of the login security
question.

(OFBIZ-11244)

Thanks Olivier Heintz for reporting and Wiebke Pätzold for providing the
patch.
2020-03-17 12:36:40 +01:00
Dennis Balkir 2895da2220 Implemented: _WARNING_MESSAGE_
(OFBIZ-10587)

Added warning message as a message type, by adding it in the
messages.ftl and the request-handler

Thanks to Niklas Fallik for reporting
2020-03-15 11:23:33 +01:00
Jacques Le Roux 67531d8bb2 Improved: "auth" should be true for all the request url used for Application
components

(OFBIZ-4956)

Currently there are some URLs present in application components with
auth="false". So anyone can hit these URLs and access these resources without
authorization.
I think all the URLs should be secure with auth="true"

jleroux: I have also fixed the dataResourceId="GZ-DIG"

Thanks: Amardeep Singh Jhajj for report and initial fix
2020-03-14 08:51:23 +01:00
Michael Brohl bb698b9b96 Implemented: Remove the user login security question.
(OFBIZ-11244)

Thanks Wiebke Pätzold for providing the patch.
2020-03-13 17:31:49 +01:00
Jacques Le Roux 308fa20e81 Improved: Remove unused ‘UtilHttp#checkURLforSpiders’
(OFBIZ-11138)

The "link.remove_lsessionid.user_agent_list" properties was forgotten
2020-03-12 15:13:42 +01:00