-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
WIP: Introduce general web secret #30929
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
Conversation
2fa9a34
to
6b03573
Compare
6b03573
to
11941bd
Compare
c084de2
to
fbe4c30
Compare
fbe4c30
to
0b85265
Compare
Will this write the new secret into the config file or how does it work? Likely we can not write anything to config files in scenarios like when the config is from env vars only. |
There is no different from the old
What this PR does is only merging the |
Name it |
I think There was already a bad example: |
As I have written in https://gitea.com/gitea/gitea-security/issues/30 I think we should use a simple plain format in the readme. The base64 value can't be written without tool support. Alowing a simple value like |
@wxiaoguang I removed backport as this is breaking, and we have already a release candidate |
I think it should be backported because it is not quite breaking and it indeed is a bug fix. |
I could agree. But for this case, the value is automatically generated, so I think end users do not need to manually touch it? |
Nothing stops us from generating just a random string without underlaying format. |
Then another question, should we stop end users if they use |
So you're saying that invalidating all OAuth2 tokens is not a breaking change and can go into patch release? I think your users might have a different idea about that. Also, this PR begs the question - why? The PR explicitly lowers security of any instance by consolidating two separate secret tokens used for different purposes into one. It is now impossible to update one token while keeping other intact, which I would consider a valid use-case. The proposed changes neither simplify code nor do anything beyond being a change for a sake of change, which raises some eyebrows considering you're touching and refactoring security-related code. |
Thank you for the questions. I will try to answer them by my understanding, correct me if I am wrong. I am not a native speaker so please understand that I could only explain my understanding directly.
I have marked it as "breaking", while I think it it acceptable for 1.22 because:
I could agree that the change is not friendly and thank you for pointing out, maybe we need to make it more friendly to end users, eg: support rotating (multiple secrets) or keep using the old secret.
In my mind, I don't think it "lowers". There are pretty many uses the for "general web secrets", see the comments: not only JWT, but also CSRF token, email validation, etc. Do you prefer to introduce dozens of "secrets" for them to "harden"? TBH I do not see the necessity at the moment. Ideally in the future Gitea should support "secret" rotating and manage these secrets automatically, then every concern could be resolved, I think this could be considered as the first step: to reduce unnecessary "secrets".
This PR is not really security-related. The real security-related one is #29205 , it has been discussed by many maintainers. It is a quick patch and has been backported to 1.21, but it does have a problem: if oauth2 is disabled, then no persistent secrets between restarts and instances. (I know 29205 is not ideal either, but indeed it seems that there is no other choice) If you are interested in the security related topic, feel free to contact me privately. |
I proposed another "quick fix" : Always load or generate oauth2 jwt secret #30942 , without changing the existing logic too much. Maybe we can take that one and leave enough time for the "secret" refactoring. (I guess there is no easy&non-breaking fix for the legacy secret problems ...... TBH I don't like these "quick fixes" either, but the real world is that, we have to move on .....) |
I think it would be valid to introduce new "general" secret that is used for internal tokens while leaving existing OAuth2 intact as separate. This would make this change only partially breaking and ready for 1.23 as while it would touch LFS-related stuff, same advice as you given out previously (to reuse old LFS secret) would be valid. |
Follow #29205
Fix #30923
No action is required for most users, Gitea will generate a proper secret when upgrading.
[oauth2].JWT_SECRET
and[server].LFS_JWT_SECRET
are removed, Gitea will generate a new[security].GENERAL_WEB_SECRET
automatically.If you'd like to keep the existing LFS signed tokens work, you could also use the old LFS_JWT_SECRET as GENERAL_WEB_SECRET.
If there are multiple processes (containers) for one Gitea instance, the config option
GENERAL_WEB_SECRET
should be the same in all config files.