Skip to content

[FSSDK-13477] Fix Arnica findings: checkout credentials, SDK key in URL, CMAB hash, demo app - #425

Open
Esra Kartal (esrakartalOpt) wants to merge 1 commit into
masterfrom
esra/fssdk-13477-fix-arnica-findings
Open

Esra Kartal (esrakartalOpt) wants to merge 1 commit into
masterfrom
esra/fssdk-13477-fix-arnica-findings

Conversation

@esrakartalOpt

@esrakartalOpt Esra Kartal (esrakartalOpt) commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the Arnica findings in FSSDK-13477 that can be fixed in code, and documents the rest.

Fixed

  • Artipacked (9): persist-credentials: false on every actions/checkout. No later step uses git.
  • Path traversal in HttpProjectConfigManager (1): the SDK key is now escaped (Uri.EscapeDataString) before it goes into the datafile URL.
  • MD5 (1): the CMAB cache attribute hash is now SHA256. An old cached entry is just a cache miss.
  • Demo app: jQuery.Validation 1.19.5 to 1.21.0, and the unused Optimizely.SDK 3.2.0 entry removed from packages.config.

Suppressed with a reason above each nosemgrep: the 2 event dispatchers (the URL comes from the SDK's own region list) and the test data loader (embedded resources, not files).

Not changed (dismiss in Arnica): 7 findings in vendored demo app scripts (third-party code, not part of the published package). The log4net finding is fixed in #426.

Test plan

  • Added a test for the SDK key escaping and one for the SHA256 hash. Both fail without the fix.
  • Built and ran the tests with Mono and NUnit 2.6.4: CMAB 22/22, dispatchers 6/6, event factory 37/37, HttpProjectConfigManagerTest 24/25. The one failure, TestSettingIfModifiedSinceInRequestHeader, fails the same way on a clean master (a timing race in the test).
  • Not tested: the Windows CI run and the demo app. Arnica needs a rescan to confirm the nosemgrep comments.

Issues

  • FSSDK-13477

🤖 Generated with Claude Code

…RL, CMAB hash, demo app jquery-validation

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@alexjoeyyong Alex Yong (alexjoeyyong) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approve with comments. Both code fixes are correct and each is pinned by a test that fails without it; I built and ran them under Mono and reproduced that. The vendored demo-app scripts match the official release byte for byte. Two comments: one wording nit (inline suggestion) and a note that part of the workflow change isn't exercised by this PR's CI.

TL;DR

  • Tests: built the SDK and tests with Mono msbuild (signed, as CI does) and ran NUnit 2.6.4: DefaultCmabServiceTest 22 of 22, HttpProjectConfigManagerTest 25 of 25 (the description saw 24 of 25, one timing-dependent test; it passed for me).
  • Both fixes are load-bearing. I put each production change back and re-ran: SHA256 -> MD5 fails HashAttributesIsSha256OfAttributesSortedByKey (Expected string length 64 but was 32); removing Uri.EscapeDataString fails TestHttpConfigManagerEscapesSdkKeyInDatafileUrl (the request URI gains a query). I also recomputed the test's expected value independently: SHA256 of {"a":1,"b":"x"} is ecf9e98ec064..., matching the test.
  • The hash change is safe to ship. AttributesHash is only compared with the stored value in the cache lookup (DefaultCmabService.cs:179); it is never sent to the CMAB service. An entry written by an older version is simply a miss.
  • The key escape doesn't change real keys. SDK keys are alphanumeric, so Uri.EscapeDataString leaves them as they are; WithUrl callers never reach that line.
  • Demo app scripts are the real thing: jquery.validate.js and jquery.validate.min.js are byte-identical (ignoring line endings) to [email protected] from npm.
  • persist-credentials: false covers all nine checkouts and the jobs that ran in CI show it working (the unit-test job logs persist-credentials: false then Removing auth).

CI: 9 pass, 1 skipped (Arnica), 1 failing: optimizely/fullstack-prod-suite (csharp). That check fails on master's last three commits and on the last three merged PRs (#421, #423, #424) too, so it isn't from this change.

Not covered by this PR's CI

  • integration_test.yml: csharp.yml calls it as optimizely/csharp-sdk/.github/workflows/integration_test.yml@master, i.e. master's copy. In the PR run the integration job's checkout logged persist-credentials: true. That file's change takes effect after merge. I read its trigger step: it only passes the token through env.
  • csharp_release.yml (4 checkouts) only runs on a release. I checked that nothing in it runs git, gh or reads .git/config, so I don't expect a change, but nothing has run it.

Proof

Results
Mono 6.12 / msbuild Release, SignAssembly with keypair.snk, NUnit 2.6.4 console
PR as pushed:    DefaultCmabServiceTest 22 run, 0 fail   HttpProjectConfigManagerTest 25 run, 0 fail
M1 SHA256->MD5:  1 failure: HashAttributesIsSha256OfAttributesSortedByKey
                 Expected: "ecf9e98ec0641e23113ff3ce8bdc78d0ddd249886517fd4a7f68cc83d4e65667"
                 But was:  "75a6ce4be04f5075316047b75a98d8eb"
M2 no EscapeDataString: 1 error: TestHttpConfigManagerEscapesSdkKeyInDatafileUrl
                 (mock SendAsync with Host == cdn.optimizely.com and empty Query/Fragment never performed)
sha256 of {"a":1,"b":"x"} (python hashlib) = ecf9e98ec0641e23113ff3ce8bdc78d0ddd249886517fd4a7f68cc83d4e65667
jquery.validate.js     vendored 9112fcdb7ef6babe  official 1.21.0 9112fcdb7ef6babe  IDENTICAL
jquery.validate.min.js vendored ba66d3685c4fdf51  official 1.21.0 ba66d3685c4fdf51  IDENTICAL
fullstack-prod-suite (csharp): failure on master c30fa1a, 6ecaa2b, 800a355 and on merged PRs #424, #423, #421
actionlint on the three changed workflows: the same findings on this head and on master
  (setup-dotnet@v2 / checkout@v2 runner "too old", SC2086 info notes). None from this PR.

Environment note: only the two fixtures touched by this PR were run (not the whole suite), under Mono and NUnit 2.6.4, not Windows msbuild and NUnit 3.18.1 as CI does. The demo app (ASP.NET) was not built.

Findings

Blockers: none. Should-fix: none.

Nits

  • Comment wording (HttpProjectConfigManager.cs:380-381, inline suggestion, principles check CODE-1.S1): "stays an empty value, as before" describes how the code used to behave. Say what it does now.
  • Bare nosemgrep (TestData.cs:99,102, HttpClientEventDispatcher45.cs:88, WebRequestEventDispatcher35.cs:60): without a rule id it suppresses every current and future rule on that line. The description is upfront that the Arnica rule ids weren't available; once Arnica shows them after the rescan, scope each one (// nosemgrep: <rule-id>). Not a suggestion block, because I don't know the ids.
  • Pre-existing and identical on master, so not asked here: integration_test.yml still uses actions/checkout@v2, which actionlint flags as too old.

Ponytail

Lean already: the fixes are one-line each, the two tests are the minimum that pin them, and the nosemgrep blocks carry the reasons the scanner can't. Nothing to cut.
net: 0 lines possible.

Principles (installed principles plugin v0.5.0, org layer; no repo-level checks)

Applied by hand, not the full recorded run. FUN-1.S1 pass (each fix has a test that fails without it; M1 and M2). FUN-2.S1 pass (the two fixtures pass; CI green apart from the pre-existing external check). SEC-4.S1 pass (the key is escaped before it reaches the URL). SEC-6.S1 pass (clears the artipacked, MD5 and path-traversal findings). CODE-1.S1: one nit ("as before", above).

Comment on lines +380 to +381
// "#" cannot change which URL is requested. A null key stays an empty value,
// as before, because the error handler above may not throw.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (principles CODE-1.S1). "stays an empty value, as before" describes what the code used to do. State what it does now:

Suggested change
// "#" cannot change which URL is requested. A null key stays an empty value,
// as before, because the error handler above may not throw.
// "#" cannot change which URL is requested. A null key becomes an empty value,
// because the error handler above may not throw.


// This is test code. The names passed to LoadJsonData are fixed strings in this class,
// and they select embedded resources of this assembly, not files on disk.
// nosemgrep

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (not a suggestion block: I don't know the rule ids). A bare nosemgrep suppresses every current and future rule on this line. The description says the Arnica rule ids weren't available. Once the rescan shows them, scope each suppression (// nosemgrep: <rule-id>). Same for line 102 here, HttpClientEventDispatcher45.cs:88 and WebRequestEventDispatcher35.cs:60.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants