CFE-3294: carry the secret tag across the bundle parameter boundary - #6328
Closed
nickanderson wants to merge 5 commits into
Closed
CFE-3294: carry the secret tag across the bundle parameter boundary#6328nickanderson wants to merge 5 commits into
nickanderson wants to merge 5 commits into
Conversation
EvalContextVariableGet() always returned the plaintext value, so a caller had no way to ask for a secret-tagged variable to be redacted. Adds a get_secret parameter and *Plaintext wrappers, and moves every existing caller onto the plaintext form. No behaviour change: every call site asks for plaintext, exactly as before. Ticket: CFE-3293 Changelog: None
EvalContextVariableGet() kept the variable's declared type while returning the redacted scalar sentinel, so an indexed read of a secret-tagged container -- mydata[key] -- took the container branch and handed that string to RvalContainerValue(), which aborts with a ProgrammingError. Deriving the type from the value actually being returned fixes it and removes the separate type_out special case. Not reachable yet: no caller passes get_secret=false until the CFE-3294 work. test_secret_container_redacts_indexed_read aborts (SIGABRT) without this and passes with it, and asserts the plaintext reads still work so redaction cannot be faked by breaking container reads. Ticket: CFE-3293 Changelog: None
VARIABLE_TAG_SECRET was a private #define in variable.c, so no code outside that file could ask whether a variable is secret -- which is what every caller that copies a value into a new variable has to do before it can propagate the tag. Moves the constant to variable.h and adds EvalContextVariableIsTaggedSecret() next to EvalContextVariableTags(). Answering via a tag set means allocating one to test a single membership, so this goes straight through VariableResolve(). No behaviour change on its own; the propagation commits that follow use it. Ticket: CFE-3294 Changelog: None
A variable whose value references a secret-tagged variable now inherits the tag, so "laundered" string => "$(password)" is no longer an ordinary variable holding plaintext that every reporting and logging path can read. Reads the value from pp->org_pp rather than the constraint the verify function is given: promises are fully expanded before verification, so by then the "$(password)" reference this keys on has already become its value. Runs on every pass, because a copy written untagged in an earlier pass stays readable for the rest of that pass. Adds FindSecretVariableReferences() in vars.c. Its traversal deliberately mirrors ExpandScalar()'s rather than factoring out a shared iterator -- restructuring a function that central does not belong in a leak fix, but the duplication is real and worth revisiting separately. Only scalar values are inspected, so a list or container assembled out of secrets does not inherit the tag yet. Ticket: CFE-3294 Changelog: Title
ScopeAugment() read each argument with the plaintext accessor and published the callee's copy with a hardcoded "source=promise" tag list, so passing a secret-tagged list or container into a bundle laundered it: the callee's copy was an ordinary variable and getvalues() returned the plaintext. Both call sites are the two branches of one if/else feeding the same switch, so both needed the tag lookup. The test asserts both directions -- the secret container must be redacted in the callee AND a non-secret container must still arrive intact -- so "no plaintext" cannot be satisfied by breaking parameter passing. Ticket: CFE-3294 Changelog: Title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ScopeAugment()published each bundle argument into the callee's scope with ahardcoded
"source=promise"tag list, so passing a secret-tagged list or containerinto a bundle laundered it — the callee's copy was an ordinary variable. The tag now
propagates across the parameter boundary.
Both call sites needed it: they are the two branches of one if/else feeding the same
switch.
Stacked on #6327.