Repository navigation
Conversation
ruanwenjun
left a comment
There was a problem hiding this comment.
We should only ensure that the content printed by the worker server itself does not contain sensitive information; there is no need to encrypt the output of the shell tasks themselves, as this should be handled by the shell itself.
Task process output (shell stdout, K8s pod logs) is produced by the user's own program which must hold the secrets in plaintext to work; masking it rewrites legitimate output. Per review on apache#18706, only logs printed by the worker server itself should be masked. Revert the taskInstanceId MDC injection in AbstractCommandExecutor so process and pod log lines are collected without per-task literal masks, matching dev behavior.
|
Thanks @ruanwenjun, addressed. Reverted the taskInstanceId MDC injection in |
|
Verified end-to-end on a standalone instance (official 3.4.3 image + this branch's jars + rebuilt UI), with a SHELL task carrying
During this E2E run I also found a pre-existing leak unrelated to this PR's changes: |
Task process output (shell stdout, K8s pod logs) is produced by the user's own program which must hold the secrets in plaintext to work; masking it rewrites legitimate output. Per review on apache#18706, only logs printed by the worker server itself should be masked. Revert the taskInstanceId MDC injection in AbstractCommandExecutor so process and pod log lines are collected without per-task literal masks, matching dev behavior.
48c469e to
3bcc56d
Compare
Register per-task sensitive prepareParams at PhysicalTaskExecutor start and clear on finalize; apply literal masks via SensitiveDataConverter using taskInstanceId MDC on process and K8s pod log collection.
… literals Register per-task sensitive values before super.initializeTaskContext so worker logs of prepareParams are masked. Skip literals shorter than 3 and apply longest-first replacement to reduce over-masking.
Task process output (shell stdout, K8s pod logs) is produced by the user's own program which must hold the secrets in plaintext to work; masking it rewrites legitimate output. Per review on apache#18706, only logs printed by the worker server itself should be masked. Revert the taskInstanceId MDC injection in AbstractCommandExecutor so process and pod log lines are collected without per-task literal masks, matching dev behavior.
Literals as short as 3 characters collide with common log text such as timestamps and numeric IDs, over-masking unrelated worker log lines. Raise the threshold to 6 to keep masking meaningful while preserving log readability.
…logs The Receive/Handle logs in PhysicalTaskExecutorOperatorImpl printed the whole TaskExecutorDispatchRequest, whose TaskExecutionContext carries sensitive prepareParams plaintext. These lines are logged on the RPC dispatch thread before per-task masks are registered and without taskInstanceId MDC, so they escaped both masking mechanisms. Log only taskInstanceId and taskName instead, verified by standalone E2E.
…rce sensitive field rule - Mask sensitive prepareParams plaintext only at worker log points: the task context dump and the logged final shell script content; the shell file written to disk keeps the real values so the task can run - Restore SensitiveDataConverter to static-regex only, drop the per-task value registry and MDC-based resolution - Introduce SENSITIVE_FIELD_RULE as a regex (currently at least 6 characters) and enforce it on the web forms (task custom params and workflow global params, red + block submit) and on the backend save/update paths; empty values and the keep-original placeholder are not affected
…g, drop point-level masking Log masking is now handled uniformly by SensitiveDataConverter (per-task sensitive values registered and matched when logs are written), so the point-level changes at log output sites are reverted: - AbstractCommandExecutor: drop sensitiveValues injection into shell builders - Shell builders: drop sensitiveValues plumbing and final-script log masking - PhysicalTaskExecutor: restore SensitiveDataConverter register/clear, drop the point-masked task context dump helper - PropertySensitiveUtils: keep only the sensitive field rule helpers, drop the log-only extract/mask string functions and their tests
…and fix validation gaps - restoreStartParams (trigger / backfill): a user-submitted plaintext overriding a sensitive workflow global must satisfy SENSITIVE_FIELD_RULE; the keep-original placeholder and empty values keep the existing semantics and are not checked - findPlaceholderProp / findInvalidSensitivePlaceholderProp / findInvalidSensitiveField: return an empty string when the offending property has a null prop, so a malformed property cannot silently bypass validation - SensitiveDataConverter: drop MIN_SENSITIVE_LITERAL_LENGTH; registration skips only empty and placeholder values, so legacy short sensitive values are masked too. The minimum length of a sensitive value is now enforced only at save time by SENSITIVE_FIELD_RULE - .gitignore: stop ignoring the whole .github/ directory (it hides upstream CI workflow files); ignore only the locally generated .github/prompts/ and .github/skills/ instead, and add the missing newline at end of file
be22151 to
b65415a
Compare
|
Thanks for working on this. I tested the current masking path and found three gaps:
Could we use a combination of structured redaction and output-level masking?
I'd also suggest dropping the six-character validation from this PR. It changes which business parameter values are accepted and still cannot prevent accidental matches in unrelated log text. Please add tests using the actual Logback layout for these cases, including process-output preservation. |
…sking for sensitive logs Address review feedback by redacting task context copies for logging, masking after full Logback layout rendering (including throwables), skipping process/pod output via an explicit marker, and dropping the six-character sensitive-value business rule.
|
Thanks @ruanwenjun, addressed in the latest commit.
Please take another look when you have a chance. |
Was this PR generated or assisted by AI?
YES. The code changes (sensitive field rule validation, log masking refactoring) and tests were AI-assisted; the design decisions and review were human-driven.
Purpose of the pull request
The worker server prints sensitive parameter values (e.g. passwords, API keys) in its own log output, which is a security risk. This PR:
SensitiveDataConverter(no per-log-statement handling).Related issue: #18588
Brief change log
Worker log masking (uniform, via
SensitiveDataConverter)PhysicalTaskExecutorregisters the task's sensitive plaintext values viaSensitiveDataConverter.registerTaskSensitiveValues(taskInstanceId, prepareParamsMap)when the task context is initialized, and clears them viaclearTaskSensitiveValuesinfinalizeTask(success / failure / kill), so values never leak across tasks.SensitiveDataConverter(logbackMessageConverter) masks both the static regex patterns (e.g. datasource password) and the per-task registered values, resolving the task from MDC.MIN_SENSITIVE_LITERAL_LENGTH(6) are skipped to avoid over-masking common log text.Sensitive field rule (min length 6)
PropertySensitiveUtils.SENSITIVE_FIELD_RULEis defined as a regex (.{6,}, i.e. at least 6 characters) so the rule can be extended later;findInvalidSensitiveFieldreturns the first offending prop name (empty values and the******keep-original placeholder are skipped).SensitivePropertyUtils.requireNoPlaceholder(create) andSensitivePropertyUtils.merge(update) reject a too-short sensitive value withServiceException, covering both workflow global params and task local params.dag-save-modal.tsx) and task custom/local params (use-custom-params.ts) validate the value when the sensitive checkbox is checked; the input is marked red and the submission is blocked. i18n messagessensitive_value_invalidadded (zh_CN / en_US).Verify this pull request
This change added tests and can be verified as follows:
PropertySensitiveUtilsTest(task-api): length boundary covered — a 5-char sensitive value is rejected, a 6-char value passes; placeholder / empty values are skipped.SensitivePropertyUtilsTest(api): create and update paths reject a too-short sensitive value and accept values satisfying the rule.SensitiveDataConverterTest(task-api): per-task register / mask / clear behavior.BaseLinuxShellInterceptorBuilderTest(task-api): final script content is written to the shell file as-is (only the logged content is masked by the converter).vue-tsctype check passes for the changed files.Pull Request Notice
Pull Request Notice: https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md
Compatibility note: saving a sensitive parameter whose value is shorter than 6 characters is now rejected (web form shows an error, backend returns an error). Existing stored values are not affected; the restriction only applies to new saves / updates. If this is considered an incompatible change,
docs/docs/en/guide/upgrade/incompatible.mdshould be updated accordingly.