Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store non-sensitive UI state without protection #5434

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Aug 26, 2024

Description

Some UI state is stored in protected browser storage: details orientation and size.

Unfortunately protected storage becomes unusable if the dashboard's data protection keys change. This can happen if the dashboard is launched from a docker container (each run has new keys). I've also seen it when updating Aspire version - perhaps the dashboard being located in a different place or a different file name causes new keys? IDK.

The fix is to store long term (localStorage) non-sensitive state without protected. Values will be remembered between runs, and there won't be errors silently thrown in the background when attempting to unencrpyt and failing.

Short term storage (sessionStorage) that is used to store potentially sensitive page data still only allows storage with protection.

I'll double check this is safe with Blazor and security folks.

Fixes #4949

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
      • Link to aspire-docs issue:
    • No
Microsoft Reviewers: Open in CodeFlow

Copy link
Member

@drewnoakes drewnoakes left a comment

Choose a reason for hiding this comment

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

Approved, assuming the security review is completed before merge.

Comment on lines +41 to +45
private ValueTask SetJsonAsync(string key, string json)
=> _jsRuntime.InvokeVoidAsync("localStorage.setItem", key, json);

private ValueTask<string?> GetJsonAsync(string key)
=> _jsRuntime.InvokeAsync<string?>("localStorage.getItem", key);
Copy link
Member

Choose a reason for hiding this comment

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

These two methods return ValueTask. I'm not sure how often these would return completed tasks, but perhaps we also use value tasks on the new methods on ILocalStorage.

@JamesNK
Copy link
Member Author

JamesNK commented Aug 26, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JamesNK JamesNK merged commit f2bdf22 into main Aug 26, 2024
11 checks passed
@JamesNK JamesNK deleted the jamesnk/unprotected-storage branch August 26, 2024 23:54
@JamesNK
Copy link
Member Author

JamesNK commented Aug 26, 2024

Approved, assuming the security review is completed before merge.

Done over email

@github-actions github-actions bot locked and limited conversation to collaborators Sep 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Protected storage configuration is lost between dashboard runs from a container
2 participants