If you ever seen a security report for one of your web applications, there is a good chance that you have seen a big warning about Clickjacking already. Clickjacking is a certain kind of attack that essentially allows the attacker to trick a victim into performing an operation that most likely they didn’t want to carry out. If you want to learn more about clickjacking then I would recommend having a read of this well detailed page.
The best way to protect against these attacks is actually rather simple: RFC 7034 describes the X-Frame-Options header that needs to be set on the HTTP responses for pages that you wish to prevent from being clickjacked. The X-Frame-Options header has three accepted values:
- DENY: the browser should never display the contents of the requested content in a frame.
- SAMEORIGIN: Only display the content in a frame, if the enclosing page(/top level browsing context — see RFC) is in the same origin as the content itself.
- ALLOW-FROM: Allows you to specify an origin from which it is allowed to display the contents of the requested resource.
How to configure OpenAM?
Since OpenAM 12.0.1 it is possible to utilize a built-in servlet filter to add arbitrary HTTP headers to our responses. The configuration of the filter is quite simple, you just have to add the following snippets to web.xml (obeying the XML schema):
<filter> <filter-name>Clickjacking</filter-name> <filter-class>org.forgerock.openam.headers.SetHeadersFilter</filter-class> <init-param> <param-name>X-Frame-Options</param-name> <param-value>DENY</param-value> </init-param> </filter> ... <filter-mapping> <filter-name>Clickjacking</filter-name> <url-pattern>/XUI/*</url-pattern> <url-pattern>/UI/*</url-pattern> <url-pattern>/console/*</url-pattern> <url-pattern>/oauth2/authorize</url-pattern> <dispatcher>FORWARD</dispatcher> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping>
The above url-patterns list is not an exhaustive list of resources that you may wish to protect, however it should serve as a good start. Alternatively you could just change the url-pattern to /* and then you only really need the REQUEST dispatcher in your filter mapping config.
Please keep in mind that there are lots of different ways to set the X-Frame-Options header for your deployment, so feel free to utilize those instead if needed.
This blog post was first published @ http://blogs.forgerock.org/petermajor/, included here with permission.