Description
Description
Related to #25034, and opening report here as per discussion with @wxiaoguang.
I want to load the four secrets into gitea, using files, because I don't want to hardcode them into app.ini
(which goes into source control).
So I have these files:
$ ls
:
.env
docker-compose.yml
INTERNAL_TOKEN
JWT_SECRET
LFS_JWT_SECRET
SECRET_KEY
And docker-compose.yml
has this (I use /run/secrets/
even though they are not real secrets, because that path is the convention):
# ...
environment:
GITEA__server__LFS_JWT_SECRET__FILE: /run/secrets/LFS_JWT_SECRET
GITEA__security__INTERNAL_TOKEN__FILE: /run/secrets/INTERNAL_TOKEN
GITEA__security__SECRET_KEY__FILE: /run/secrets/SECRET_KEY
GITEA__oauth2__JWT_SECRET__FILE: /run/secrets/JWT_SECRET
volumes:
- ./INTERNAL_TOKEN:/run/secrets/INTERNAL_TOKEN:ro
- ./JWT_SECRET:/run/secrets/JWT_SECRET:ro
- ./LFS_JWT_SECRET:/run/secrets/LFS_JWT_SECRET:ro
- ./SECRET_KEY:/run/secrets/SECRET_KEY:ro
And each file contains a secret:
./INTERNAL_TOKEN
created using$ gitea generate secret INTERNAL_TOKEN
./JWT_SECRET
created using$ gitea generate secret JWT_SECRET
./LFS_JWT_SECRET
created using$ dd if=/dev/urandom bs=1 count=32 status=none | base64 | tr '/+' '_-' | tr -d '='
./SECRET_KEY
created using$ gitea generate secret SECRET_KEY
I start it, and check the logs, where I see this:
2023/06/17 06:41:03 ...s/setting/setting.go:371:CreateOrAppendToCustomConf() [I] Settings for security.INTERNAL_TOKEN saved to: "/data/gitea/conf/app.ini"
2023/06/17 06:41:03 ...s/setting/setting.go:371:CreateOrAppendToCustomConf() [I] Settings for server.LFS_JWT_SECRET saved to: "/data/gitea/conf/app.ini"
Notice it only mentions security.INTERNAL_TOKEN
and server.LFS_JWT_SECRET
. It does not mention the other two.
Also, it writes this to app.ini
:
[server]
LFS_JWT_SECRET__FILE = /run/secrets/LFS_JWT_SECRET
LFS_JWT_SECRET = ...secretsecretsecretsecretsecretsecretsecretsecret...
[security]
INTERNAL_TOKEN__FILE = /run/secrets/INTERNAL_TOKEN
INTERNAL_TOKEN = ...secretsecretsecretsecretsecretsecretsecretsecret...
SECRET_KEY__FILE = /run/secrets/SECRET_KEY
[oauth2]
JWT_SECRET__FILE = /run/secrets/JWT_SECRET
Notice LFS_JWT_SECRET
and INTERNAL_TOKEN
are hardcoded into the file. That is not good, as it's what we are trying to avoid. The app.ini
file exists on the host and is now leaking secrets to those who can read it. Also it's interesting that it does that for two files only, but not the other two.
I realise the env-to-ini feature is doing exactly it's job. But maybe there needs to be "exclusions" for those four secrets? Those should not be written to the config file, but used by gitea directly. Is that possible?
Gitea Version
1.19.3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
See log lines above
Screenshots
No response
Git Version
I'm using gitea in docker. Host has git 2.39.2
Operating System
debian 12
How are you running Gitea?
docker compose, see above
Database
SQLite