eduardo lazaro zevallos created SPARK-62424:
-----------------------------------------------
Summary: [CONNECT][PYTHON] The Connect client logs JDBC options,
including the password, in plain text
Key: SPARK-62424
URL: https://issues.apache.org/jira/browse/SPARK-62424
Project: Spark
Issue Type: Bug
Components: Connect
Affects Versions: 4.0.0, 4.1.0, 3.5.1
Environment: PySpark Connect client 3.5.1, 4.0.0 and 4.1.0 (Python)
Reporter: eduardo lazaro zevallos
The PySpark Connect client logs the full unresolved plan from
pyspark.sql.connect.client.core ("Executing plan ...", "Schema for plan: ...").
The text comes from _proto_to_string(), which only shortens the plan and does
not mask anything.
For spark.read.jdbc(...) or format("jdbc").option("password", ...), the plan
holds the data source options, so the password, user and JDBC URL go to the log
in plain text:
Schema for plan: root { ... read { data_source { format: "jdbc" ...
options \{ key: "password" value: "<plain text>" }
options \{ key: "url" value: "jdbc:..." } options \{ key: "user" value: "..."
} } } ... }
- 3.5.x: logged at INFO, so normal application logs show it.
- 4.x / master: logged at DEBUG, but still not masked.
The server already masks options with spark.sql.redaction.options.regex and
spark.redaction.regex. The Python client does not mask anything.
Steps to reproduce:
import logging
from pyspark.sql import SparkSession
logging.basicConfig(level=logging.DEBUG) # INFO is enough on 3.5.x
spark = SparkSession.builder.remote("sc://localhost:15002").getOrCreate()
spark.read.format("jdbc").option("url", "jdbc:postgresql://db/x") \
.option("user", "u").option("password", "s3cret").option("dbtable",
"t").load().schema
# The log contains: key: "password" value: "s3cret"
Expected: the client masks option values whose keys match the redaction pattern
(default: keys that contain password, secret or token) before it logs a plan.
Workaround: a logging.Filter on the pyspark.sql.connect logger that masks those
values.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]