Skip to content

feat: enforce some props to be secret on RisingWave Cloud #21248

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

Merged
merged 18 commits into from
Apr 14, 2025

Conversation

tabVersion
Copy link
Contributor

@tabVersion tabVersion commented Apr 5, 2025

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

Highest Release Version: 2.3

What's changed and what's your intention?

as title, relate https://linear.app/risingwave-labs/issue/CLOUD-3897/%5Bdiscussion%5D-enforce-secret-for-sensitive-fields-on-cloud

Enforce sensitive fields to be SECRET when create SOURCE/SINK(in #21269)/CONNECTION

For cluster matching BOTH condition:

Then the kernel will do such enforcement.

manually test loacally

set_env RISINGWAVE_CLOUD "1"

dev=> create table t1( a int, b varchar )  with ( connector = 'kafka', properties.bootstrap.server = 'localhost:9092',
  topic = 'test2', properties.sasl.password = 'demo') format plain encode json ;
ERROR:  Failed to run the query

Caused by these errors (recent errors listed first):
  1: connector error
  2: Enforce Secret Error
  3: properties.sasl.password is enforced to be a SECRET on RisingWave Cloud, please use `CREATE SECRET` first

resolve #20946

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • My PR contains critical fixes that are necessary to be merged into the latest release.

Documentation

  • My PR needs documentation updates.
Release note

Introduce new system setting enforce_secret_on_cloud (default to false for open source, on-prem and byoc, default to true for cloud-hosted instance)


detect ENV RISINGWAVE_CLOUD as the signal for the instance is running on RisingWave Cloud

  • enforces some props have to be SECRET when creating source/table.

enforce SECRET props:

### AWS (mainly for loading schema from aws s3)
- access_key
- aws.credentials.access_key_id
- s3.access.key
- secret_key
- aws.credentials.secret_access_key
- s3.secret.key
- session_token
- aws.credentials.session_token

### Kafka
- properties.ssl.key.pem
- properties.ssl.key.password
- properties.sasl.password

### Pulsar
- pulsar.auth.token

### Kinesis
- kinesis.credentials.access
- kinesis.credentials.secret
- kinesis.credentials.session_token

### NATS
- password
- jwt
- nkey

### Iceberg
- s3.access.key
- s3.secret.key
- gcs.credential
- catalog.credential
- catalog.token
- catalog.oauth2_server_uri

### MQTT
- tls.client_cert
- tls.client_key
- password

### Filesystem (S3)
- s3.credentials.access
- s3.credentials.secret

### Filesystem (GCS)
- gcs.credential
- gcs.service_account

### Filesystem (Azblob)
- azblob.credentials.account_key
- azblob.credentials.account_name

### Google Pubsub
- pubsub.credentials

### Iceberg (Catalog)
- catalog.jdbc.password

### TestSource
- No specific secrets enforced (placeholder)

### DummyProperties
- No specific secrets enforced (placeholder)

comes from #21352

enforce secrets for new create CONNECTION

### Kafka: the same as Kafka source

### IcebergConnection: 
- s3.access.key
- s3.secret.key
- gcs.credential
- catalog.token

### ConfluentSchemaRegistryConnection
- schema.registry.password

### ElasticsearchConnection:
- elasticsearch.password

@tabVersion tabVersion requested a review from Copilot April 5, 2025 09:21
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

prop_iter: impl Iterator<Item = &'a str>,
) -> ConnectorResult<()> {
for prop in prop_iter {
IcebergCommon::enforce_one(prop)?;
Copy link
Preview

Copilot AI Apr 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the enforce_secret_on_cloud implementation for IcebergProperties, secret enforcement is performed twice (once via IcebergCommon::enforce_one and again via Self::enforce_one). Consider consolidating these calls to avoid redundant validations.

Suggested change
IcebergCommon::enforce_one(prop)?;

Copilot uses AI. Check for mistakes.

@kwannoel kwannoel self-requested a review April 5, 2025 18:01
@@ -85,6 +85,7 @@ parking_lot = { workspace = true }
parquet = { workspace = true }
paste = "1"
pg_bigdecimal = { git = "https://github.com/risingwavelabs/rust-pg_bigdecimal", rev = "0b7893d88894ca082b4525f94f812da034486f7c" }
phf = { version = "0.11", features = ["macros"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

Copy link
Contributor

@kwannoel kwannoel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anyway to disable this on cloud, if some unforseen circumstance is encountered, and for already created source, will this affect backwards compatbility?

@tabVersion
Copy link
Contributor Author

Is there anyway to disable this on cloud, if some unforseen circumstance is encountered, and for already created source, will this affect backwards compatbility?

I am considering following the issue suggested alter system.
The check only happens in create object stage so it should not have backwards compatibility issue.

@tabVersion
Copy link
Contributor Author

also do we want to enforce secret when CREATE CONNECTION? If we just want to reuse some sensitive fields, we can directly ask for the privilege of CONNECTION, no bother enforcing anything.
cc @lmatz @kwannoel

@kwannoel
Copy link
Contributor

kwannoel commented Apr 9, 2025

also do we want to enforce secret when CREATE CONNECTION? If we just want to reuse some sensitive fields, we can directly ask for the privilege of CONNECTION, no bother enforcing anything. cc @lmatz @kwannoel

Does this mean that in RWC, they must always create connection for source and sinks, and cannot fill in the fields inline?

@tabVersion
Copy link
Contributor Author

tabVersion commented Apr 9, 2025

also do we want to enforce secret when CREATE CONNECTION? If we just want to reuse some sensitive fields, we can directly ask for the privilege of CONNECTION, no bother enforcing anything. cc @lmatz @kwannoel

Does this mean that in RWC, they must always create connection for source and sinks, and cannot fill in the fields inline?

I don't mean that. Using CONNECTION and filling inline are two alternatives. Users can grant us using CONNECTION, it does not expose the credentials in plaintext.
As long as do reduction well for CONNECTION, we do not need to enforce secret when creating CONNECTION or enforce using connection in source/sink creation. In this pr, we will enforce secrets for CREATE SOURCE/SINK/CONNECTION.

@tabVersion tabVersion marked this pull request as draft April 9, 2025 08:04
@lmatz
Copy link
Contributor

lmatz commented Apr 9, 2025

I support enforcing secret also when creating CONNECTION.
The motivation is to eliminate the possibility of leaking users' credentials as much as possible.
Because once the leak happens, it becomes a mess, and it is hard to explain.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 32 out of 32 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/connector/src/source/iceberg/mod.rs:77

  • [nitpick] The enforcement loop calls both IcebergCommon::enforce_one(prop) and Self::enforce_one(prop) for every property. Consider reviewing if both checks are necessary or if the logic can be consolidated to avoid potential redundancy.
for prop in prop_iter { IcebergCommon::enforce_one(prop)?; Self::enforce_one(prop)?; }

src/connector/src/source/cdc/mod.rs:150

  • [nitpick] The empty implementation for EnforceSecretOnCloud in CdcProperties may bypass secret enforcement. Consider either implementing the intended checks or documenting why enforcement is intentionally omitted.
impl<T: CdcSourceTypeTrait> EnforceSecretOnCloud for CdcProperties<T> {} // todo: enforce jdbc like properties

@tabVersion tabVersion marked this pull request as ready for review April 11, 2025 08:24
@tabVersion tabVersion enabled auto-merge April 14, 2025 04:19
Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Cargo.lock changes

@tabVersion tabVersion added this pull request to the merge queue Apr 14, 2025
Merged via the queue into main with commit 2e1ab81 Apr 14, 2025
40 of 41 checks passed
@tabVersion tabVersion deleted the tab/force-secret branch April 14, 2025 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System config to ban plain-text secrets
6 participants