hasura / hasura/graphql-engine

disallow applying metadata with hardcoded db urls

Open
#8,199 0 comments 0 reactions 0 assignees View on GitHub
c/server k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

From v2.0 onwards Hasura stores db connection config in its metadata. As Hasura allows using raw db connection strings as the connection config, this can lead to the db url on any Hasura instance on which the metadata is applied to get replaced inadvertently which can be disastrous. e.g. if not careful, one can end up replacing their prod database with a dev testing database on a production hasura instance when attempting to apply new metadata changes to it.

### Describe the solution you'd like

Hasura should reject metadata application if there are hard coded db urls in the metadata.

the [replace_metadata API](https://hasura.io/docs/latest/graphql/core/api-reference/metadata-api/manage-metadata.html#replace-metadata) should reject requests which have metadata with hard coded db urls and only allow db connection config as env vars. A new arg, e.g "skip_db_url_env_check", maybe added to disable this behaviour.

The console and CLI can show a warning when this scenario occurs and can have the option to bypass the error by adding the skip_check flag and retrying if the user confirms so.

Contributor guide

Open the contributing guide

Research direction

Start with the replace_metadata API described in the issue and trace how metadata containing database connection configuration is validated. Define the rejection and explicit bypass behavior for hardcoded URLs, then review the requested console and CLI warning paths; done means unsafe metadata is rejected by default and the confirmed bypass remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.