Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about session and csrf #31

Open
anibalardid opened this issue Dec 20, 2018 · 7 comments
Open

question about session and csrf #31

anibalardid opened this issue Dec 20, 2018 · 7 comments

Comments

@anibalardid
Copy link

Hi Omar, how are you ?
I'm trying your framework , I like it very much.
But I have problems with csrf ... at beggining it works, but after some minutes it doesnt work anymore.
When I create post it said error 400 and in logs appear "invalid CSRF token", I added Session::getCsrfToken() to the same debug line, and it appears empty.

What could be happening ?

Best regards !

@ghost
Copy link

ghost commented Dec 20, 2018

What are the values of your config/config.php about expire the cookie and session? Did you change the crsf_token_time to something else?

@anibalardid
Copy link
Author

Hi ! Thanks for your reply.
I didn't change these values.
These are as default in the code

@anibalardid
Copy link
Author

anibalardid commented Dec 21, 2018

I debug the code, adding new logger in the same method that check csrf, I add debug_backtrace() to see where are passing the code ...
I don't see Session in this trace.
I think, maybe, the code sometimes doesn't initialize session ...

I attached it here:
https://pastebin.com/urEdxb6y

@Achterstraat
Copy link

Achterstraat commented Jan 4, 2019

Hi,

You can modify line 59 from core/Sessions.php from..

if(!self::validateIPAddress($ip) || !self::validateUserAgent($userAgent)) {

..to..

if(!self::validateIPAddress($ip)) {

..and test then again, if no invalid sessions your useragent returns unstable reliable results!

Or..

if(!self::validateIPAddress($ip) || !self::validateUserAgent($userAgent)) {

..to..

if(!self::validateUserAgent($userAgent)) {

..and test then again, if no invalid sessions your IPv4/IPv6 are switching random!

@anibalardid
Copy link
Author

when I only let validateipaddress:

05/01/2019 9:51:59 | /shared/httpd/lightframeworks/htdocs/miniPHP/app/core/components/SecurityComponent.php | 238 | CSRF Attack
User: 1 provided invalid CSRF Token 35722d62fcb28368ffe2571677f84f18


05/01/2019 9:51:59 | /shared/httpd/lightframeworks/htdocs/miniPHP/app/core/components/SecurityComponent.php | 136 | Exception
The request has been deined


If I let validateuseragent...
same error (400)

05/01/2019 9:53:04 | /shared/httpd/lightframeworks/htdocs/miniPHP/app/core/components/SecurityComponent.php | 238 | CSRF Attack
User: 1 provided invalid CSRF Token d12d121d050f01a0949e428884027eae


05/01/2019 9:53:04 | /shared/httpd/lightframeworks/htdocs/miniPHP/app/core/components/SecurityComponent.php | 136 | Exception
The request has been deined


@goldwizard13
Copy link

goldwizard13 commented Feb 2, 2022

when I only let validateipaddress:

05/01/2019 9:51:59 | /shared/httpd/lightframeworks/htdocs/miniPHP/app/core/components/SecurityComponent.php | 238 | CSRF Attack
User: 1 provided invalid CSRF Token 35722d62fcb28368ffe2571677f84f18

05/01/2019 9:51:59 | /shared/httpd/lightframeworks/htdocs/miniPHP/app/core/components/SecurityComponent.php | 136 | Exception
The request has been deined

If I let validateuseragent... same error (400)

05/01/2019 9:53:04 | /shared/httpd/lightframeworks/htdocs/miniPHP/app/core/components/SecurityComponent.php | 238 | CSRF Attack
User: 1 provided invalid CSRF Token d12d121d050f01a0949e428884027eae

05/01/2019 9:53:04 | /shared/httpd/lightframeworks/htdocs/miniPHP/app/core/components/SecurityComponent.php | 136 | Exception
The request has been deined

hi i have the same problem, how did you solve it?

@anibalardid
Copy link
Author

hi i have the same problem, how did you solve it?

I finally removed it, and I created some other checks created by my own.

I modified a lot this framework to do what i need to do :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants