fix(crypto): Gate IV nonce-reuse warning to Raw format [STUD-80532]#575
Open
alexandru-petre wants to merge 3 commits into
Open
fix(crypto): Gate IV nonce-reuse warning to Raw format [STUD-80532]#575alexandru-petre wants to merge 3 commits into
alexandru-petre wants to merge 3 commits into
Conversation
…532] The design-time IV nonce-reuse warning on EncryptText/EncryptFile fired for every wire format, but only Raw consumes an IV — the runtime rejects an IV on Classic/Owasp2026/OpenSslEnc via Validation_Iv_OnlyForRaw. The warning therefore cried wolf in unrelated contexts and desensitized users before a real Raw + explicit-IV reuse risk. Gate the warning on Format == SymmetricWireFormat.Raw in both CacheMetadata overrides so it mirrors the runtime invariant. Tests: pin the positive case (Raw still warns) and add negative reproducers across Classic/Owasp2026/OpenSslEnc for both activities, asserting the warning is suppressed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… [STUD-80532]
Standardize the five IV-warning assertions on exact equality against
Resources.Iv_NonceReuseWarning instead of two inconsistent substring
predicates. The negative variant previously OR'd in a dead Contains("nonce")
term the message never carries; exact equality removes the guesswork and
survives any future reword of the warning text.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-80532] PGP encryption ignores Format/Iv entirely — Execute routes to the PGP path when Algorithm == PGP, bypassing the symmetric helper. Hand-edited or persisted XAML carrying Algorithm=PGP with a leftover Raw IV still tripped the design-time warning. Add Algorithm != EncryptionAlgorithm.PGP to both CacheMetadata guards so the warning matches runtime IV consumption exactly. Adds PGP regression tests for EncryptText and EncryptFile. Found via Codex cross-validation (round 1 Minor). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
There was a problem hiding this comment.
Pull request overview
This PR adjusts the design-time (CacheMetadata) IV nonce-reuse warning in the Cryptography activities so it only appears in configurations where an explicit IV is actually consumed at runtime (symmetric encryption with Format = Raw), avoiding misleading warnings for non-Raw formats and for PGP.
Changes:
- Gate the IV nonce-reuse validation warning on
Iv != null && Format == SymmetricWireFormat.Raw && Algorithm != EncryptionAlgorithm.PGPin bothEncryptTextandEncryptFile. - Update/expand unit tests to cover the new gated behavior (Raw warns; non-Raw and PGP do not).
- Standardize assertions to compare warning messages via exact resource equality (
== Resources.Iv_NonceReuseWarning) using aCryptoResalias for clarity.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Activities/Cryptography/UiPath.Cryptography.Activities/EncryptText.cs | Tightens CacheMetadata IV warning so it only triggers for symmetric + Raw (and not PGP). |
| Activities/Cryptography/UiPath.Cryptography.Activities/EncryptFile.cs | Mirrors the same IV warning gate change for file encryption activity consistency. |
| Activities/Cryptography/UiPath.Cryptography.Activities.Tests/CacheMetadataWarningTests.cs | Adds/updates tests to validate the new warning gating and uses exact resource-string matching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.



Context
EncryptTextandEncryptFile(UiPath.Cryptography.Activities) are thesymmetric/PGP encryption activities in the Cryptography package. At design time
they raise validation warnings from
CacheMetadatathat Studio surfaces on theactivity. One such warning, added under STUD=64429 / STUD=80231 alongside the
Rawwire format and the explicitIvproperty, cautions against reusing a(Key, IV)pair.Problem Statement
The IV nonce-reuse warning fired far too eagerly. Its only guard was
if (Iv != null), with no regard for the selected wireFormatorAlgorithm.An IV is consumed only by the
Rawformat on symmetric algorithms — theruntime rejects an IV on
Classic/Owasp2026/OpenSslEnc(
SymmetricInteropHelper,Validation_Iv_OnlyForRaw) and PGP ignores itentirely. So an author who set an
Ivand then switched away fromRawkeptseeing the alarming "NEVER reuse (Key, IV)" warning in contexts where no IV is
used — desensitizing them before a real Raw + explicit-IV reuse risk.
Behavior Before This PR
An author sets
IvonEncryptText, then setsFormat = Classic(or picksAlgorithm = PGP). The design-time warning "NEVER reuse the same (Key, IV)pair…" still shows, even though that configuration never consumes the IV at
runtime.
Behavior After This PR
Same scenario: with
Format = Classic(or any non-Raw format), or withAlgorithm = PGP, no IV warning is shown. The warning appears only for the oneconfiguration that actually consumes an explicit IV — symmetric algorithm +
Format = Raw— exactly mirroring the runtime's IV-consumption path.Considered Use Cases
Raw+ explicit IV → warns (the real reuse risk).Classic/Owasp2026/OpenSslEnc+ IV → no warning (runtime rejects the IV).Raw+ empty IV → no warning (legitimate "generate a random IV per call").PGP+Raw+ IV (hand-edited/persisted XAML) → no warning (PGP ignores Format/Iv).Implementation
The
CacheMetadataguard becomesIv != null && Format == SymmetricWireFormat.Raw && Algorithm != EncryptionAlgorithm.PGPin both activities.
FormatandAlgorithmare plain properties (notInArgument), so they are readable at design time. The wrapper-vs-value aspectof
Iv != null(a touched-but-empty IV field) is intentionally left as-is perthe ticket — it can't be reliably evaluated from
CacheMetadata, and "Raw +empty IV" is a valid configuration.
Test assertions for this warning were standardized on exact resource equality
(
w.Message == Resources.Iv_NonceReuseWarning) instead of brittle substringmatching, via an aliased
usingto disambiguate the productionResourcesclass from the test project's own
Resourcesnamespace.How to Test
dotnet test Activities/Activities.Cryptography.sln --filter "FullyQualifiedName~CacheMetadataWarningTests"— 18/18 pass.Format == Raw/Algorithm != PGPgate is removed (verified), confirming they're genuine reproducers.dotnet test Activities/Activities.Cryptography.slnstays green.