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

Enable auditing of user activity in Graphana shared Vertica connection #31

Open
scherepanov opened this issue Dec 24, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@scherepanov
Copy link

scherepanov commented Dec 24, 2022

Hi,

I am looking at user audit from Graphana in Vertica.

As expected, Graphana is completely anonymise user activity. Vertica connection reports OS version, OS username, account used for connection. It is not known what user actually run query.

That most likely is same for any database connection, not only Vertica.

That is a hard problem to address, as same Vertica connection is being used to run queries for many users.

One approach that can work is to inject final user info into SQL text. Graphana can add to SQL text comment like this:

select
/* user=traceable_user */
from ....

Vertica strip comments outside SQL, i.e. before first and after last SQL keyword. Comment should be injected inside SQL.

That probably would take some efforts to implement...

If you have other ideas, how to enable auditing of user activity through Graphana. Please post it here. Each SQL issued by Graphana should be traceable back to user who originated it.

It is actually a serious problem, security and audit has very high priority.

In my Vertica environment, this is a very big reason to use per-user Vertica connection #30

Thanks for reading!

@verticacrossman
Copy link
Contributor

Hi,

We have been reviewing this alongside your issue 30 as there is some overlap. A couple quick notes:
Our sql go driver actually prevents SQL injection on purpose and that in itself is a huge security risk.

It appears that Grafana doesn't expose the logged in user name (based on review of internal env vars shown with Volker Labs Env plugin). They also limit the env vars that Grafana service will allow for security reasons. So if we did allow sql injection we most likely could not programmatically get the logged in user name to pass in.

Vertica supports labels on queries. It's not clear if the username could be found whether it could be dynamically added as a dashboard variable. At first glance it doesn't look like it as the variables are hard coded and there's no internal env var to pick it up from.

The search continues.

@scherepanov
Copy link
Author

Thanks for looking into issue!

labels are hard to use. I implemented adding label to generated SQL text on in-house system.
I can see only around 30% of SQL get label recognized and processed by Vertica.

Problem is that label is required to follow main SELECT keyword.

First I added label after first SELECT keyword. It work properly in a very few cases, because users used WITH SELECT a lot.

Now I am adding label to last SELECT. Works properly only with 30% of SQL. Users typically doing complicated joins…

To add LABEL properly, you need to fully parse SQL… which is not possible and not practical.

Sooooo…..

Adding label to SQL is same as adding plain comment to SQL. It works fine, I can search in SQL text, but not understandable by Vertica.

I do not think adding comment qualify for SQL injection.

Yes, adding comment with keyword and username will provide reasonable audit capabilities. You can do comment in LABEL format, just do not expect it to be working properly every time.

@tanvipise tanvipise added the enhancement New feature or request label Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants