Hiding a button is not protecting it: Check<Role>Role on the server
It's one of the most common security flaws in OutSystems apps, and one of the most tested in the Security Specialist exam: hiding a button from users without permission and assuming the action is protected. It isn't. This article shows why and how to fix it.
The situation
In a pharmacy's stock app, the Adjust stock button is hidden from anyone who isn't a pharmacist, with Visible = False. A curious clerk opens the browser's developer tools, sees that the screen calls the AdjustStock Server Action and replays the call with other values. The stock changes.
The button was hidden. Why didn't that help?
The client is in the user's hands
In a Reactive app, everything that runs on the client becomes HTML, JavaScript and CSS in the browser: screens, Client Actions, screen variables, Client Variables and input parameters. All of it can be read and changed by whoever is using the app.
Hiding or disabling a button only changes the interface. The Server Action is still there, and anyone who knows how to call it, by forging the request, runs the code. The interface is a convenience for the user; security lives on the server.
How to really protect it
1. Roles on the screen
Each screen's Roles property defines which roles can open it; the user needs at least one of them. Besides blocking navigation, it makes the endpoints the screen uses require a logged-in user with those roles.
2. A check at the start of the Server Action
Every Server Action that does something sensitive should start by validating the caller:
GetUserId()to know who the user is. Never takeUserIdas an input parameter: the client can send any value.Check<Role>Role(GetUserId())to check the permission. For each role, OutSystems creates theCheck<Role>Role,Grant<Role>RoleandRevoke<Role>Roleactions.- Without permission, raise an exception and don't run the rest.
In the example, AdjustStock should start with CheckPharmacistRole(GetUserId()). To avoid repeating the logic, you can centralize the check in service actions reused by several screens.
3. Visible beats Enabled, but neither protects
To control the interface, prefer Visible over Enabled: a button that is only disabled stays on the page and shows that the action exists. But neither property replaces the server-side check.
4. Check at the moment of the action
Checking permissions only when the screen loads is not enough. The user may have an old tab open or lose the role along the way. The check that counts is the one inside the action, when it runs.
Tools that help
- TrueChange, in Service Studio, shows security warnings, for example when client logic calls a Server Action that changes data without revalidating.
- OutSystems' code quality tool, now called Code Quality (formerly AI Mentor Studio and Architecture Dashboard), also flags insecure patterns.
In ODC the principle is the same: roles on screens and a role check at the start of Server Actions.
How it shows up in the exam
Expect scenarios like "a user without permission managed to run an operation that was hidden in the interface; what's the cause?" or "which of these does not protect a sensitive action?". The traps:
- Hidden button ≠ protected action.
- Disabling is even worse than hiding: the action is still visible.
UserIdas an input parameter is a vulnerability.- A role on the screen doesn't replace the check in the action, because the action can be called from elsewhere.
Try it in your environment
- Find a Server Action that changes data in one of your apps.
- Check whether it starts by validating the user and role. If not, add
Check<Role>Role(GetUserId())and an exception. - Hide the button for a user without the role and try calling the action from the browser's developer tools, replaying the network request. It should be refused.
This is one of the Access Control topics, worth 3 or 4 questions in the exam. See the full map in Security Specialist: what the exam is like and how to study.
Bloquest is independent and not affiliated with OutSystems.