How to prevent of Client HTML5 Store Sensitive data In Web Storage in Asp.net core Angular

Sumanth Babu 21 Reputation points
2022-07-25T05:50:16.743+00:00

Client HTML5 Store Sensitive data In Web Storage in my code below

private readonly _authToken: string = this.encrypt('auth_token');

set authToken(value: string)
{
localStorage.setItem(this._authToken, this.encrypt(value)); --> "this._authToken" Store Sensitive data attack
}

Please help to my code . If got let me know

Developer technologies ASP.NET ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-07-25T16:22:05.03+00:00

    you can not securely encrypt on the client, only has. You should not pass secure data to the client that the client is not allowed to view, keep it on the server.

    if you must, have the server encrypt the data, which the client can safely store, and send to the server at a later time.

    note: proper auth tokens are clear text by design (they are signed instead), and do not need to be encrypted. you can safely store the in local storage (at least on a private hosted web browser)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.