RE: WebInspect 1789 Vulnerabilities

Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Hello,
Has anyone done any penetration testing with Liferay 7.0 CE GA3 using Fortify WebInspect. 
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
It is highly likely that many of these are false positives. Tools will typically falsely identify Liferay code as vulnerable for one thing or another but without any knowledge of how Liferay actually works.

Sure, the tool might be able to submit a url that changes the login_redirect parameter to login_redirectAttack and Liferay responds, but you have to actually look at the response to see that Liferay has likely quietly consumed and discarded it completely. Tools will falsely claim this is a vulnerability, when in fact it is not vulnerable at all.

Will you be able to get Liferay to not be vulnerable to the 1789 items they found? No, not in the slightest. Does that mean Liferay is vulnerable? No, not likely.

If you are required to resolve those 1789 before you can launch? You're not going to be successful. The other side will need to accept that the 1789 are likely false positives and discard the results; then it will be your job to verify that each of those are actually false positives and prove that they have no real impact.
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Thanks for your response David, but the application is already in production. I only used the out of box classic theme and  the only changes that were made was customizing the document library screen which I added an extra component to the document upload screen and a new metadata field.
 I will submit these findings to Fortify WebInspect as false positives. 
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
I have lost track of the number of times I have had this conversation with security groups over the years. I even had one report once that claimed that Liferay was executing shell commands that were passed to it. Obviously it doesn't lol -- but to make the point, I bet the client the value of my next invoice and asked them to submit the command rm -rf / emoticonMy own experiences are the same as David -- false positives. Most notably, most of these tools assume that if a 200 OK Response comes back from a request then it automatically means that it did whatever was submitted. When I dig into these scenarios (now I have never committed to reviewing 1700 of them, but I have done as many as 100+ -- which was really boring), the results showed that the urls were returning a 200 OK and that the actual result was the Portal Error page -- meaning Liferay detected an invalid request and didn't do anything. I'm willing to bet that most of your results fall into this scenario.You could submit something to Fortify, but I doubt anything would change. These are false positives in Liferay, in other tools they may be deemed as perfectly valid results. Ideally there would be a way to mark a test as a false positive to have it eliminated from future runs -- but outside of that, I think you have to eye ball them. That's what I always end up doing. 
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Thanks Andrew. yes all the results showed a 200 OK . I will submit to fortify as false positive as the results will return portal error page and liferay detected invalid request. Hopefully this would be a sufficient challenge. 
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
<p>Hi Andrew, I have attached the summary list for all the vulnerabilities were found. I would like to submit for false positive as you had describe in your previous experience with these scanning tool&nbsp;. Could let know if these were same vulnerabilities you had as well?</p>
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hey Kevin,
The attachments came through as pngs -- with no real detail, so it's hard to say from your attachments. Normally I was working with a very large PDF that provided all the test details, one test per page. I was able to see the URL, the payload sent, the response, etc. Do you have anything like that you can share?
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Hi Andrew, yes I do have a PDF report. Attached is the pdf scan report.  A majority of the vulnerabilities are 
  • clickjacking,
  •  Misconfigured Content Security Policy: missing strict-dynamic, 
  • Missing HTTP Strict-Transport-Security

It seems this scan tool is looking for some specific response header values. Are these all false positives ?
For most of the clickjacking WebInspect Recommendation:Use the 'frame-ancestors' directive of the Content Security Policy. You must set the value to, 'none', 'self', or an allowed https source
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Are they false positives? I think so...

Let's consider the clickjacking thing. To implement this, a hacker needs to be able to inject a layer over top of a button in order to hijack the click.

How would they do this in Liferay? Content is normally managed by admins, so a hacker cannot (in a normal configuration) create the HTML or script content to apply the overlay. Portlets are canned presentation, so a hacker cannot inject things there. On any type of Liferay input form such as forum posts, blog entries, etc the input is scrubbed of <script /> tags or at the very least encoded so it is not going to be executed b the browser.

The only way a hacker could get to a point where they had this working, they'd need to be able to intercept the response stream between what is generated by Liferay and what is returned in the browser. And, if the hacker can do that, they can strip all of these other response headers and do lots of even worse manipulations.

So sure, Liferay doesn't generate any frame-ancestors headers. I'd argue that it really doesn't need to. That said, if you really want to include these headers on your site, well you control the theme so feel free to add what you want. But do you really need to? No, because there's so many other things that have to go wrong before a hacker could exploit it that this header becomes the least of your worries.

Strict-dynamic, well that's a choice you need to make, but from the dynamic nature of the portal some support might not be possible. The nonce, for example, would need to be applied to the theme, across all of the tag libraries, web contents, nasty portlet scriptlet code, ... Some of these changes would be easy, others would be impractical if not impossible. I mean, you can write a web content that contains a script tag, but how are you going to know what nonce to assign and how to enforce it?

And finally HSTS is again an implementation choice, not a portal requirement. The portal doesn't care if you host it under HTTP or HTTPS, it will continue to work either way. You can require HSTS, but it is something you need to configure for and, again since you control the theme, you can add the HSTS header all day long if that's what you want.

So yes, I'd consider all of these to be false positives. They are not product issues, they are implementation issues...
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Thanks David for your response emoticon. They are valid points and I believe I should be able to use for the fall positive challenge.  The task is how to proceed whether to challenge or implement. It will take a considerable amount of work to add the frame ancestor headers thats if the challenge was denied. For worst case, if the challenge was denied and implementation need to take place, is it possible to add the headers in the apache web server or portal-ext.properties file?
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Why not just add to the theme if they must be there?

Definitely not a portal-ext.properties issue.

I think apache has a mod to modify/add headers, but you have to ask yourself if you want to pay the performance penalty it may have injecting into every single response...
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Ok if needed to implement, I will use in my theme. Is there a main page I can add the response header that will override all the pages? Or do I update all the jsp pages that were tag vulnerable in the report?
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Less for you Kevin, but more for anyone else who comes along a sees this and has a slightly different setup. One advantage of susing hte proxy (as Christoph has suggested) is that it doesn't have a dependency on your plugin to be in effect. Also, if you are someone that is using the multi-site feature of Liferay, or even has more than one theme for a single site (eg. a theme for the public pages, and a separate one for the private pages) then you'd have to be sure to make the same change everywhere (all themes) to have the same security in place across the board. Again, not necessarily applicable to your case (in fact, possibly overkill) but in case someone else reads this thread -- food for thought.
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Thanks Andrew,
Fortunately, I don't have multiple multiple sites. I  only have a custom theme that's has a basic introduction on the landing home page and a change to the footer content on the home page. 
So just to recap, to resolve the following below :clickjackcking, -> add  :Use the 'frame-ancestors' in response headers implement on the apache server. Misconfigured Content Security Policy: missing strict-dynamic ->   add the Content Security Policy header to apache server -per Christopher commentMissing HTTP Strict-Transport-Security ->  allow https secure protocal only. disable http request.  per David comment
thumbnail
Christoph Rabel, modified 6 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Since you wrote that you have an Apache webserver, I would add the Content Security Policy header there.
What we don't know here is if you load javascript from a cdn or elsewhere. If you do that, you have to add the nonce to the script tags requesting the resource.
e.g. in Apache
Header set Content-Security-Policy "script-src ‘somenoncecode’"
<script src=“https://code.jquery.com/jquery-3.4.1.min.js” nonce=“somenoncecode”></script>
I am not sure what happens if you use the Liferay cdn setting. It is quite possible that you need to hook the jsps referenced in the theme (e.g. top_head.jsp).
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Thanks Christopher for your point.
I will see to get midtier  to add the security policy header to apache webserver. I don't believe I am loading the javascript from liferay cdn.
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Andrew Jardine:

I have lost track of the number of times I have had this conversation with security groups over the years. I even had one report once that claimed that Liferay was executing shell commands that were passed to it. Obviously it doesn't lol -- but to make the point, I bet the client the value of my next invoice and asked them to submit the command rm -rf / emoticonMy own experiences are the same as David -- false positives. Most notably, most of these tools assume that if a 200 OK Response comes back from a request then it automatically means that it did whatever was submitted. When I dig into these scenarios (now I have never committed to reviewing 1700 of them, but I have done as many as 100+ -- which was really boring), the results showed that the urls were returning a 200 OK and that the actual result was the Portal Error page -- meaning Liferay detected an invalid request and didn't do anything. I'm willing to bet that most of your results fall into this scenario.You could submit something to Fortify, but I doubt anything would change. These are false positives in Liferay, in other tools they may be deemed as perfectly valid results. Ideally there would be a way to mark a test as a false positive to have it eliminated from future runs -- but outside of that, I think you have to eye ball them. That's what I always end up doing. 

Andrew, the repsponse gets back is 200 but I dont see portal error page but just the home page. Is this a vulnerability if there is no portal error page because a false positive I am using is that there was no action taken from Liferay as it accept request and discard the repsone by presenting the ehome page. Can you advise?

Another clickjacking item is whenever a .js is reference in the URL doing a GET it returns the entire javascript page for exmaple http://localhost:8080/o/frontend-js-metal-web-1.0.7/metal-dom/src/events.jso/frontend-js-metal-web-1.0.7/metal-dom/src/events.js. Is this a vulnerable issue?

Also, do you or anyone know how to Remove X-Powered-By and its value from the reponse hearder in Liferay ?
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Andrew, the repsponse gets back is 200 but I dont see portal error page but just the home page. Is this a vulnerability if there is no portal error page because a false positive I am using is that there was no action taken from Liferay as it accept request and discard the repsone by presenting the ehome page. Can you advise?

I have seen this, but honestly I can't recall the exact use case for when it happens. Can you give me one of the urls that you are trying when it returns your to the home page? I am wondering if perhaps it is a private page you are trying to hit without an authenticated session so it're rerouting you to the default public page (homepage).

Another clickjacking item is whenever a .js is reference in the URL doing a GET it returns the entire javascript page for exmaple http://localhost:8080/o/frontend-js-metal-web-1.0.7/metal-dom/src/events.jso/frontend-js-metal-web-1.0.7/metal-dom/src/events.js. Is this a vulnerable issue?

I'm not clear on the problem with the JS. The response from the server contains references to JS files (like just about every web application these days .. css files too for that matter). The browser makes separate requests to download those files so that it can use them in the rendered page. /o is just the filter that liferay uses to understand the the request is looking for a resource. 


Also, do you or anyone know how to Remove X-Powered-By and its value from the reponse hearder in Liferay ?​​​​​​​

I've never looked because, quite honestly, I've never cared that it was there emoticon. I'll bet if you search the portal source though you'll find it. 
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
RE: Scan results Pen test
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Andrew Jardine:

Andrew, the repsponse gets back is 200 but I dont see portal error page but just the home page. Is this a vulnerability if there is no portal error page because a false positive I am using is that there was no action taken from Liferay as it accept request and discard the repsone by presenting the ehome page. Can you advise?

I have seen this, but honestly I can't recall the exact use case for when it happens. Can you give me one of the urls that you are trying when it returns your to the home page? I am wondering if perhaps it is a private page you are trying to hit without an authenticated session so it're rerouting you to the default public page (homepage).

Another clickjacking item is whenever a .js is reference in the URL doing a GET it returns the entire javascript page for exmaple http://localhost:8080/o/frontend-js-metal-web-1.0.7/metal-dom/src/events.jso/frontend-js-metal-web-1.0.7/metal-dom/src/events.js. Is this a vulnerable issue?

I'm not clear on the problem with the JS. The response from the server contains references to JS files (like just about every web application these days .. css files too for that matter). The browser makes separate requests to download those files so that it can use them in the rendered page. /o is just the filter that liferay uses to understand the the request is looking for a resource. 


Also, do you or anyone know how to Remove X-Powered-By and its value from the reponse hearder in Liferay ?​​​​​​​

I've never looked because, quite honestly, I've never cared that it was there emoticon. I'll bet if you search the portal source though you'll find it. 


Sample Attack payload. I don't believe its a private page.
http://localhost:8080/c/portal/render_portlet?p_l_id=20150&p_p_id=com_liferay_site_navigation_menu_web_portlet_SiteNavigationMenuPortlet&p_p_lifecycle=0%0d%0aSPIHeader:%20SPIValue&p_t_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=null&p_p_col_pos=null&p_p_col_count=null&p_p_static=1&p_p_isolated=1&currentURL=%2Fportal%2Frender_portlet&settingsScope=portletInstance
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
The only way to know for sure for that one is to look up the p_l_id value in the Layout table in the database. Regardless, all that URL is doing is asking Liferay to render the navigation portlet that is associated with that page. I'd hardly call that an attack -- or if it is "an attack", it's a pretty pathetic one emoticon
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Andrew Jardine:

Andrew, the repsponse gets back is 200 but I dont see portal error page but just the home page. Is this a vulnerability if there is no portal error page because a false positive I am using is that there was no action taken from Liferay as it accept request and discard the repsone by presenting the ehome page. Can you advise?

I have seen this, but honestly I can't recall the exact use case for when it happens. Can you give me one of the urls that you are trying when it returns your to the home page? I am wondering if perhaps it is a private page you are trying to hit without an authenticated session so it're rerouting you to the default public page (homepage).

Another clickjacking item is whenever a .js is reference in the URL doing a GET it returns the entire javascript page for exmaple http://localhost:8080/o/frontend-js-metal-web-1.0.7/metal-dom/src/events.jso/frontend-js-metal-web-1.0.7/metal-dom/src/events.js. Is this a vulnerable issue?

I'm not clear on the problem with the JS. The response from the server contains references to JS files (like just about every web application these days .. css files too for that matter). The browser makes separate requests to download those files so that it can use them in the rendered page. /o is just the filter that liferay uses to understand the the request is looking for a resource. 


Also, do you or anyone know how to Remove X-Powered-By and its value from the reponse hearder in Liferay ?​​​​​​​

I've never looked because, quite honestly, I've never cared that it was there emoticon. I'll bet if you search the portal source though you'll find it. 


I was able to removed the X-Powered by removing its entry from standalone.xml jboss/wildfly10.0
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Hate to sound cynical, but do you think they really care?

I mean, at the end of the day it is possible to create a bad theme or a bad portlet or include a bad chunk of JS which would create a new vulnerability in your portal. If you tell them "every alert generated against a Liferay-based site is a false positive", how would they catch these kinds of issues?

And Liferay version can play a role here, too. It could be that running this against an older, unpatched version of Liferay that out of the 1789 issues, perhaps there are a couple of real vulnerabilities. The tool would not likely be able to determine "I'm running against 7.0 GA3 so these XXX results are now false positives"...

I'm just not sure how you separate the wheat from the chaff here. Tools typically aren't smart enough to realize when they are identifying a false positive because it requires too much knowledge of Liferay to know when a renamed attribute would be a problem or not, for example. Liferay would likely not want to waste cycles combing through the 1789 to see if there are any true failures in there, so that kind of leaves it up to you.
Kevin Matthews, modified 6 Years ago. Expert Posts: 253 Join Date: 1/25/16 Recent Posts
Hi David I am running Liferay 7.0 GA3.
Most of these vulnerabilities are the same such  click  jacking, Cross site Scripting etc. Below are the most common issues.