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

[Security] Grafana v10.4.2 (22809dea50) x Postgresql: Why does Grafana query the pg_authid system catalog? #87551

Open
3BK opened this issue May 9, 2024 · 5 comments
Assignees
Labels
needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc

Comments

@3BK
Copy link

3BK commented May 9, 2024

What happened?

Why does Grafana query the pg_authid system catalog?

This catalog is not publicly readable by design because it contains passwords.

Grafana sent this to PostgreSQL:

SELECT oid, rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolconnlimit, rolpassword, rolvaliduntil, rolreplication, rolbypassrls, pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, rolname = current_user AS is_current_user FROM pg_authid WHERE rolname !~ '^pg_' ORDER BY 2

By design, Grafana should have sent this to PostgreSQL:

SELECT oid, rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolconnlimit, rolpassword, rolvaliduntil, rolreplication, rolbypassrls, pg_catalog.shobj_description(oid, 'pg_roles') as rolcomment, rolname = current_user AS is_current_user FROM pg_roles WHERE rolname !~ '^pg_' ORDER BY 2

What did you expect to happen?

I expected Graphana to query pg_roles instead of pg_authid .

Did this work before?

Don't know.

How do we reproduce it?

  1. Spin up grafana latest + postgresql latest
  2. Connect Grafana to postgresql
  3. Boom

Is the bug inside a dashboard panel?

The bug is in tsdb.postgresql

Environment (with versions)?

Grafana: Grafana v10.4.2 (22809de)
OS: *NIX
Browser: Chrome (latest)
Postgresql: 16.2

Grafana platform?

A package manager (APT, YUM, BREW, etc.)

Datasource(s)?

tsdb.postgresql

Tasks

No tasks being tracked yet.
@3BK 3BK changed the title Grafana v10.4.2 (22809dea50) x Postgresql: Why does Grafana query the pg_authid system catalog? [Security] Grafana v10.4.2 (22809dea50) x Postgresql: Why does Grafana query the pg_authid system catalog? May 9, 2024
@3BK
Copy link
Author

3BK commented May 9, 2024

What's even more interesting is that the Grafana repository doesn't appear to contain any obvious references to pg_authid .

@3BK
Copy link
Author

3BK commented May 9, 2024

@tonypowa Is this within your purview? To wit. Why does Grafana need to inventory all database passwords on connection?

@3BK
Copy link
Author

3BK commented May 9, 2024

Adding @yesoreyeram and @gabor as a second set of eyes.

@gabor
Copy link
Contributor

gabor commented May 10, 2024

hi @3BK , i cannot reproduce this with the postgres datasource. i tried with the commit you mentioned, and no such query was sent to the database by the datasource plugin.

are you using the postgres datasource, or are you using postgres as the database that grafana uses to run( i mean the https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#database setting)?

@gabor gabor self-assigned this May 10, 2024
@gabor gabor added the needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc label May 10, 2024
@3BK
Copy link
Author

3BK commented May 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc
Projects
Status: In Progress
Development

No branches or pull requests

2 participants