Agent pool Postgres DSN is logged in cleartext, including the password, while the auth DSN is redacted
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 49.2k
- Forks
- 4.5k
- Avg merge
- 1d 3m
- Merged PRs (30d)
- 239
Description
LocalAI version
v4.9.0 (localai/localai:latest-gpu-nvidia-cuda-12, revision f7ad3f70eb5d8a0ddf80e08557f0d7df28cf032e)
Describe the bug
When the agent pool uses the Postgres vector engine, LocalAI logs the full
LOCALAI_AGENT_POOL_DATABASE_URL at INFO level, including the database
password in cleartext, every time it opens a collection.
The auth database URL is redacted correctly in the same log stream, so the
redaction helper already exists. It just is not applied on this path.
Redacted (correct), from LOCALAI_AUTH_DATABASE_URL:
INFO Auth enabled database="postgresql://%2A%2A%2A:%2A%2A%2A@postgres:5432/localai_auth?sslmode=disable"
Not redacted, from LOCALAI_AGENT_POOL_DATABASE_URL (password replaced by hand
before pasting here):
INFO PostgreSQL collection collectionName="AML" databaseURL="postgresql://localai_user:REDACTED-PASSWORD@postgres:5432/localai?sslmode=disable"
One line is emitted per collection on every start, so the credential is
repeated and persists in whatever collects container logs. In a Docker
deployment these sit on disk under the json-file driver and are readable by
anyone who can read container logs, for example through a management UI,
without any access to the environment or the compose file.
To Reproduce
- Set
LOCALAI_AGENT_POOL_VECTOR_ENGINE=postgresand
LOCALAI_AGENT_POOL_DATABASE_URL=postgresql://user:password@host:5432/db?sslmode=disable - Have at least one agent collection defined.
- Start LocalAI and read the log.
The PostgreSQL collection line contains the password verbatim.
Expected behavior
The agent pool DSN should be redacted in logs the same way the auth DSN
already is, or the log line should print only the host, port and database
name rather than the whole URL.
Additional context
Not configurable from the outside: the value has to be a DSN, so there is no
way for an operator to avoid this short of not using the Postgres vector
engine. Rotating the password does not help, because the new one is logged
too.
Suggested fix: apply the same redaction used for the auth DSN to the agent
pool DSN before logging.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Find the PostgreSQL collection log path for the agent pool and compare it with the auth database logging path that already redacts its DSN. Reproduce the issue with a PostgreSQL agent-pool DSN, apply the existing redaction approach to the logged value, and verify that the password no longer appears in the collection log.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- backend, databases, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 75/100