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

Reduce discoverability of session cookie name and add RFC 6265 support #4763

Closed
wants to merge 1 commit into from
Closed

Conversation

summercms
Copy link
Contributor

@summercms summercms commented Nov 12, 2019

While researching a different issue, I came across this post: laravel/laravel#4305

Laravel link: https://github.com/laravel/laravel/blob/5.8/config/session.php#L127-L130

I leave this open for the admins to discuss and look deeper into this.

@LukeTowers
Copy link
Contributor

@ayumi-cloud while I appreciate the thought, we're not going to make this change, we don't include env() calls in our default config so that the project is more approachable to developers not familiar with Laravel (we do support them, we just don't include it by default, we have the october:env command to switch out config files to use env() calls).

I would say that this is more of a neat practice that individual projects can decide whether or not they want to enable it, so if you would like to submit this to https://octobertricks.com/ then I would recommend doing that instead.

@LukeTowers LukeTowers closed this Nov 12, 2019
@summercms summercms deleted the rfc-6265 branch November 12, 2019 21:57
@Samuell1
Copy link
Member

I think this should done when ocms will be updated to laravel 6.0 version. (I done some changes already in my fork: Samuell1@7598cfa )

@LukeTowers I think maybe this can be exception, because env values have callback to other option if they are not defined.

@LukeTowers
Copy link
Contributor

@Samuell1 I don't see the point. The only reason to make this change is one of security through obscurity by trying to prevent people from detecting what platform is running by looking at the cookies generated. There's so many other ways to identify that October is in use that it seems pointless to me.

@Samuell1
Copy link
Member

@LukeTowers Thats true, but i think configs that are inherited from laravel should correspodent with laravel configs to make it simplier.

@LukeTowers
Copy link
Contributor

@Samuell1 simpler for who exactly? That's a considerably more complex value than the current one that can be understand easily enough by us having this discussion but isn't immediately obvious as to what the purpose of it is to anyone else that's not familiar with why anyone would want to have that value. For that reason, the reason that it doesn't really add any value out of the box for most users, and the fact that individual projects using October can always choose to put whatever they want there themselves I don't think we'll reconsider adding it.

@summercms
Copy link
Contributor Author

@LukeTowers @Samuell1 I wanted to ask, instead of making the config messy, could this RFC 6265 support just be included into the parser side?

@LukeTowers
Copy link
Contributor

@ayumi-cloud I have no idea what you're talking about

@summercms
Copy link
Contributor Author

summercms commented Nov 15, 2019

@LukeTowers

In RFC 6265, the cookie name is specified as an RFC 2616 token, which means you can pick from the alphanums plus: !#$%&'*+-.^_`|~

So what I was asking is, does October escape the cookie name in the parser, according to the RFC 6265 protocol?

Basically, add the RFC 6265 whitelist to October's parser for escaping the cookie name.

@LukeTowers
Copy link
Contributor

@ayumi-cloud October does whatever Laravel does, so if you want to check that, check Laravel's code.

@summercms
Copy link
Contributor Author

summercms commented Nov 15, 2019

@LukeTowers laravel doesn't do it at the parser level, they do it direct in the config file, which makes no sense to me. It would make more sense to do all the escaping at the same level. As October doesn't use the .env in the configs to make it easier for newbie's. October could create a more cleaner approach by moving it into the parser level.

p.s. I'm talking about the code line here: https://github.com/laravel/laravel/blob/c4a7a7bc9cdccd00d6fdda8846d1660a0608d7ef/config/session.php#L129

I don't understand why Laravel puts a Str:: in the config when it can be cleaner to do the same thing in the parser instead.

Of course totally up to you.

(Hope you get what I mean)


[edit]

It looks like the cookie name is just going straight in here: https://github.com/illuminate/session/blob/a95be1a3bf2cc26256b094c637813331dae56cd4/Middleware/StartSession.php#L155

and

https://github.com/illuminate/session/blob/a95be1a3bf2cc26256b094c637813331dae56cd4/Middleware/StartSession.php#L94

Looks like nothing in October could stop me adding funny characters into the cookie name as nothing is being escaped.

The point of the RFC 6265 is to escape the cookie name.

@summercms
Copy link
Contributor Author

@LukeTowers

I'm saying this:

Laravel does this

image

October does this

image

I'm asking should it be like this

image

@Samuell1
Copy link
Member

Samuell1 commented Nov 15, 2019

@ayumi-cloud Its just config value it doesnt send your cookie name there. it only uses october_session cookie name.

@summercms
Copy link
Contributor Author

@Samuell1 my point is that the cookie name spec allows certain characters, right now October is not filtering them at all.

See here what I mean: https://stackoverflow.com/questions/1969232/allowed-characters-in-cookies

@LukeTowers
Copy link
Contributor

@ayumi-cloud I really don't think it's a concern TBH, if a developer decides to be goofy and change the session name to something with disallowed characters then it's on them to identify and fix that since there is no reason for them to do so.

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

Successfully merging this pull request may close these issues.

3 participants