Skip to content

(PA-8346) Harden sensitive parameter preservation against regressions - #390

Closed
gavindidrichsen wants to merge 1 commit into
mainfrom
pa-8346-add-updates
Closed

(PA-8346) Harden sensitive parameter preservation against regressions#390
gavindidrichsen wants to merge 1 commit into
mainfrom
pa-8346-add-updates

Conversation

@gavindidrichsen

Copy link
Copy Markdown
Contributor

Summary

Follow-up to PR #388 which fixed the cleartext leak of sensitive parameters during Puppet::Resource → Hash conversion. This PR hardens that fix in three ways:

  • Replace fragile attributes[:sensitive_parameters] injection with set_sensitive_parameters — PR (PA-8346) Preserve sensitive parameters #388 injected :sensitive_parameters into the attributes hash before super, relying on hash2resource's undocumented internal key-deletion to clean up the extra key. This works today but couples to an implementation detail of Puppet core. This PR uses the public Puppet::Type#set_sensitive_parameters API after super instead, which is both the intended API and resilient to upstream changes in hash2resource.

  • Add a re-wrap guard after canonicalize — Providers that implement canonicalize receive unwrapped attribute values. If a provider returns a plain string where a Sensitive-wrapped value was expected, the sensitive wrapping is silently lost. This PR adds a post-canonicalize re-wrap pass (identical to the existing pre-canonicalize one) so that the Sensitive wrapper survives regardless of provider behavior.

  • Add the missing regression test — PR (PA-8346) Preserve sensitive parameters #388's tests covered the "no sensitive params" case and the Sensitive-wrapping case, but did not test the primary fix path: a Puppet::Resource input carrying a non-empty sensitive_parameters list with unwrapped values. This PR adds that test, directly asserting parameter(:secret).sensitive == true and that the value is re-wrapped as Sensitive — the test that would catch a reintroduction of the original bug.

Test Plan

  • Existing specs continue to pass
  • New spec when loading from a Puppet::Resource with sensitive parameters listed verifies:
    • parameter(:secret).sensitive returns true
    • The secret value is re-wrapped as Puppet::Pops::Types::PSensitiveType::Sensitive

Related

PR #388 fixed the cleartext leak of sensitive parameters by injecting
:sensitive_parameters into the attributes hash before super. This
follow-up hardens that fix in three ways:

1. Replace the fragile attributes[:sensitive_parameters] injection
   (which relies on hash2resource's undocumented key-deletion) with
   an explicit post-super set_sensitive_parameters call using the
   public Puppet::Type API.

2. Add a re-wrap guard after canonicalize to catch providers that
   may unwrap Sensitive values during canonicalization.

3. Add the missing regression test that directly asserts
   parameter(:secret).sensitive == true when a Puppet::Resource
   carries sensitive_parameters -- the test that would catch a
   reintroduction of the original bug.
@gavindidrichsen
gavindidrichsen requested review from a team as code owners June 30, 2026 12:16
@gavindidrichsen
gavindidrichsen marked this pull request as draft June 30, 2026 12:38
@gavindidrichsen gavindidrichsen added the research A research or design task label Jun 30, 2026
@gavindidrichsen

Copy link
Copy Markdown
Contributor Author

Closing this. Can possibly re-open at a later date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

research A research or design task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant