Code

No localStorage in client scripts.


Security
A04: Insecure Design
1h 45m to fix

Why is this an issue?

localStorage is a javascript function that allows you to save information based on a specific key, for example:

1localStorage.setItem("bestInstanceAnalyzer", "Fixr");

This way, at any time you can request for this information in the code:

1var analyzer = localStorage.getItem("bestInstanceAnalyzer");

However, this is not the best way, since the data is saved exclusively on the client, which is a major security breach. Sensitive information and personal data are very exposed and with little protection.

Best practices

The safe way to do this type of operation is to save the data on the server side and then request this information on the client. There are different ways to do it, the best known are GlideAjax API and even the REST API. However in this article, we will bring an example of how to do it using the user session.

Basically, this method consists of saving the information in the user's session (through the server) and then requesting it via client.

On server-side, you can put information in session as show:

1gs.getSession().putClientData("myData", "Hello, world!");

And in client-side, you can get this information:

1//Variable `message` has a "Hello, world!" value 2var message = g_user.getClientData("myData");

That way, in client, you will only be reading the information, which will be stored only on the server.

You can also clear this session information (in server-side) by calling clearClientData() and passing the data key as a parameter:

1gs.getSession().clearClientData("myData");
Do not use current.update() in Business Rules
Do not use hard coded sys_id

© Copyright 2025. All rights reserved.