csrf-protection

Not able to authenticate post request for CSRF token with tomcat

安稳与你 提交于 2019-12-01 19:21:01
I am working on a tomcat application. I am trying to add CSRF authentication token provided by catlina library(org.apache.catalina.filters.CsrfPrevention). I have added filter to web.xml <filter> <filter-name>CsrfFilter</filter-name> <filter-class>org.apache.catalina.filters.CsrfPreventionFilter</filter-class> <init-param> <param-name>entryPoints</param-name> <param-value>/Login</param-value> </init-param> </filter> <filter-mapping> <filter-name>CsrfFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> Also I have updated the login.jsp <% String url = '/Login?x=true'; String

Doubt on prevention of CSRF

↘锁芯ラ 提交于 2019-12-01 13:07:34
I had one doubt about CSRF prevention. A lot of sites say that CSRF can be prevented by using 'tokens' which are randomly generated per session. Now my doubt is, suppose i have a function like : $.post("abcd.php",{'fbuid':userid,'code':'<?php echo md5($_SESSION['randcode']); ?>'} now this md5 hash would obviously be visible to any hacker through the source code.He could simply open this page, generate a token, and keep the page open, so that the session doesn't get destroyed, and useanother tab or anything else , to start hacking, No ? Or is my idea of tokens incorrect ? Thanks for your help

laravel 5 csrf_token value is Empty

匆匆过客 提交于 2019-12-01 06:42:48
Why laravel 5 csrf_token value is empty always ? How can i get that token value ? I tried, {!! csrf_token !!} , {{ csrf_token }} and {{ Form::open() }} ....{{ Form::close() }} MY OUTPUT <input type="hidden" name="_token"></input> Victor Hugo Avelar It's because you're not using the web group middleware. Laravel is smart enough to know that if you're not using that group a token is not necessary. Try moving your route inside the Route::group(['middleware' => 'web'] ... and tell us about it :) Source: I made the same mistake not too long ago. I stumbled across this post having spent the

Same-Site cookie in Spring Security

六月ゝ 毕业季﹏ 提交于 2019-12-01 04:23:17
问题 is it possible to set Same-site Cookie flag in Spring Security? See: https://tools.ietf.org/html/draft-west-first-party-cookies-07 And if not, is it on a roadmap to add support, please? There is already support in some browsers (i.e. Chrome). T.H. 回答1: You can always set cookie values by yourself in the Java world if you can get an instance of the HttpServletResponse . Then you can do: response.setHeader("Set-Cookie", "key=value; HttpOnly; SameSite=strict") In spring-security you can easily

How to enable CSRF protection in JSF-Spring integrated application

落爺英雄遲暮 提交于 2019-12-01 01:07:47
I have a JSF-Spring integrated application. Spring security is also integrated in this application. These are the versions in my application: JSF 2.2 Spring 4.0.3.RELEASE Spring Security 3.2.4.RELEASE As per the JSF doc all the POST request in JSF2.x [or even old versions] will be CSRF protected. However I am able to penetrate my application with CSRF attack. I tried a different JSF2.2 only [no Spring] example application, in that case I can see this example application is CSRF protected. So my understanding is, the JSF/Spring /Spring security combination is giving issue in my original

Play 2.5.4 - how to implement CSRF filters?

为君一笑 提交于 2019-11-30 16:23:36
How does one implement CSRFfilters in Play 2.5.4? The play documentation is wrong (doesn't compile, and can't under the play 2.5.4 java api), the example here doesn't compile ( Play 2.5 disable csrf protection for some requests ). the 2.5 java API has a CRSFFilter class but it is not a sub class of EssentialFilter so cannot be added to the array of EssentialFilters because it is the wrong type. Is this functionality currently broken for Play 2.5.4 or is the documentation currently misleading/wrong? This code works fine for me, Play 2.5.4 Java. Create app/Filters.java file and put this import

Difference between CSRF and X-CSRF-Token

北城以北 提交于 2019-11-30 13:17:21
问题 What is the difference between use X-CSRF-Token in header or token in hidden field ? When use hidden field and when use header and why? I think that X-CSRF-Token is when i'm using javascript/ajax but im not sure 回答1: CSRF protection comes in a number of methods. The traditional way (the "Synchronizer token" pattern) usually involves setting a unique valid Token value for each request and then verifying that unique value when the request is subsequently sent in. It is usually done by setting a

Difference between CSRF and X-CSRF-Token

ぃ、小莉子 提交于 2019-11-30 08:58:56
What is the difference between use X-CSRF-Token in header or token in hidden field ? When use hidden field and when use header and why? I think that X-CSRF-Token is when i'm using javascript/ajax but im not sure CSRF protection comes in a number of methods. The traditional way ( the "Synchronizer token" pattern ) usually involves setting a unique valid Token value for each request and then verifying that unique value when the request is subsequently sent in. It is usually done by setting a hidden form field. The token value is usually short lived and associated to that session, so if a hacker

File upload in Struts2 along with the Spring CSRF token

前提是你 提交于 2019-11-30 08:22:55
问题 I use, Spring Framework 4.0.0 RELEASE (GA) Spring Security 3.2.0 RELEASE (GA) Struts 2.3.16 In which, I use an in-built security token to guard against CSRF attacks. <s:form namespace="/admin_side" action="Category" enctype="multipart/form-data" method="POST" validate="true" id="dataForm" name="dataForm"> <s:hidden name="%{#attr._csrf.parameterName}" value="%{#attr._csrf.token}"/> </s:form> It is a multipart request in which the CSRF token is unavailable to Spring security unless

How can I disable Django's csrf protection only in certain cases?

风格不统一 提交于 2019-11-30 08:07:49
I'm trying to write a site in Django where the API URLs are the same as user-facing URLs. But I'm having trouble with pages which use POST requests and CSRF protection. For example, if I have a page /foo/add I want to be able to send POST requests to it in two ways: As an end user (authenticated using a session cookie) submitting a form. This requires CSRF protection. As an API client (authenticated using a HTTP request header). This will fail if CSRF protection is enabled. I have found various ways of disabling CSRF, such as @csrf_exempt, but these all disable it for the entire view. Is there