Cross-site request forgery Yii ,PHP - security

I am trying to implement CSRF validation in yii . I have written my own class and everything works fine except the fact that my post variable(for the form) does not consist of the token . Am I supposed to set the token myself in the post variable ? Yii documentation states that the post variable is set by a hidden field in every form . Does it require further implementation in the forms as well ? I know the token is not there as I saw the Post variables by dumping them .

I guess everything you need is enable CSRF validation in your config and use CHtml for forms (Yii Guide). Here what you need in config:
'components'=>array(
'request'=>array(
'enableCsrfValidation'=>true,
),
),

In addition to enabling CSRF validation, you need to put the Yii CSRF token in your form. One of the easiest ways I've run into to put it in is to use CHtml beginForm, which puts it in as part of producing your form tag. More info here: http://www.yiiframework.com/doc/api/1.1/CHtml#beginForm-detail

Related

how to extract token generated by js script (challenge.flood.io)

I am currently studying Gatling for performance testing, I am new to both. Making the task, I have stuck on the step when I need to get a token to pass it to parameter to get to the other page.
The difficulty for me is that the token is absent in the body, it is generated by a script, so I cannot get it with ...check(css(... or check(regex(...
I tryed to get the token by css and regex, getting empty result
.exec(
http("Step 5 page")
.get("${redirection}")
.check(status.is(200))
.check(substring("Step 5"))
.check(css("input[name='challenger[step_id]']", "value").find.saveAs("step_id"))
.check(css("input[name='challenger[step_number]']", "value").find.saveAs("step_number"))
.check(css("input[name='commit']", "value").find.saveAs("commit"))
.check(css("span.token").find.saveAs("one_time_token")))
How can I get the token?
It's pretty clear from this code that this page is performing an extra ajax request to the /code url to fetch the token and then display it in the page.
You'll find the value in there (you can see this HTTP request a few lines below in the Network tab).
Note: in order to learn Gatling you should probably check the Gatling Academy.

While performing load testing on SharePoint app, it shows error for WinAuth, how to resolve it?

I have recorded the script in JMeter, and while validating it, it is throwing an error for the winauth/sso, how to resolve it. my app has oAuth and me have to authenticate it.
I'm running the script for WinAuth, it gets highlighted in red color and under Response Body, it is displaying "Unauthorized"
I have added the HTTP Cookie Manager (check CookieManager.save.cookies=true in jmeter.properties), HTTP Authorization Manager.[images are added down the below for verification purpose]
I'm not able to view the Token_id also.
Images:
1. showing winAuth sso error
2. showing all parameters with its respective values.
You have to do at least three steps:
Add HTTP Cookie Manager (and check
CookieManager.save.cookies=true in jmeter.properties)
Add HTTP Authorization Manager
Using the Regular Expression Extractor extract Authentification token from the first request (from login page) and send it to the second requests.
See that article to get ideas about how to use the Regular Expression Extractor to extract authentication token https://dzone.com/articles/how-to-load-test-saml-sso-secured-websites-with-jm

How To Get XSRF Token value from blogger.com to post content

I have contents for blogger.com at my mongo db, and I want create python script to post the contents to blogger.com.
When I look developer console when publish a post at developer console. I need to pass some value,
{
"method":"editPost",
"params":"{\"1\":1,\"2\":\"wadaw\",\"3\":\"ffrdgd\",\"4\":\"3425436456546\",\"5\":0,\"6\":0,\"7\":1,\"9\":0,\"10\":2,\"11\":1,\"12\":[\"grdhth\"],\"13\":0,\"14\":{},\"15\":\"en\",\"16\":0,\"17\":{\"1\":2017,\"2\":12,\"3\":18,\"4\":21,\"5\":32},\"20\":0,\"21\":\"\",\"22\":{\"1\":1,\"2\":{\"1\":0,\"2\":0,\"3\":0,\"4\":0,\"5\":0,\"6\":0,\"7\":0,\"8\":0,\"9\":0,\"10\":\"0\"}},\"23\":1,\"27\":0,\"28\":0}",
"xsrf":"AOuZoY7tEYY0lUcn9E2mDmaJil5uHpTCnw:23543543141"
}
When i search what is xsrf, it should be placed at hidden value / session / cookie, but I didnt't find it ?
is there any method to get xsrf value ?
actually, I have search another method to do this. Its to use blogger api, but is it possible to get oAuth2 token without google prompt ?
Your answer is regex like:
"xsrf":"(.+?)"

Does Kohana Formo prevent CSRF

Does Formo module for Kohana prevent CSRF? I haven't seen any code (tokens etc.) form protecting forms against it. So, is there any built-in solution in Formo or I have to protect forms on my own?
Thanks
Kohana has basic support for CSRF protection.
Check these links:
Docs: http://forum.kohanaframework.org/discussion/2052/csrf-helper/p1
Forum: http://kohanaframework.org/3.2/guide/api/Security#token
It basically means you have to put a token in your forms manually with Security::token();
Like this:
echo Form::hidden('csrf', Security::token());
Then you can check the token where you handle the form via validation:
$array->rules('csrf', array(
'not_empty' => NULL,
'Security::check' => NULL,
));

req.body returning "Forbidden"

In my node.js express app I'm submitting a form, to an action on a controller.
All this controller does is:
send(req.body)
(I'm using RailwayJS (but that's not all that important to this question I don't think)
I'm doing this is to get the values in the form
However, it comes back as 'Forbidden'
If I restart node, and refresh the page (confirming i want to post back) then I get the desired result...
Any idea how to get the values of the form without restarting?
I think this is related to 'protect from forgery' beforeFilter. Do you pass authencity_token to your post?
Possible solution: skipBeforeFiler('protect from forgery'); -- it disables CSRF protection
Better solution: use form_for helper, or pass authencity_token manually. Check apidocs to learn more about CSRF protection: http://jsdoc.info/1602/express-on-railway/helpers.html#instance/csrf_tag

Resources