Step-by-Step Guide to Secure Business Central Agent Implementations in AL
This post demonstrates how to secure AI agents in Business Central by implementing restrictive profiles, page customizations, and permission sets. It shows the security risks of overly permissive agent configurations and provides step-by-step AL code examples to limit what agents can see and do.

post Aardvark Labs
"We have to assume that if the Agent can do something the agent will do that thing. It is like Murphy's Law."
Key points
- Agents navigate pages like users do, so they should be restricted with profiles and permissions and trusted as little as possible
- The first version gave the agent the Business Manager profile plus several broad D365 permission sets, far more access than its task needed
- Page customizations that clear the layout and actions, a custom role center, and a profile limit which pages and fields the agent can see
- A custom permission set gives read-only access to Customer, Vendor and Employee Ledger Entry data and execute rights on the needed objects, and the setup codeunit now assigns this permission set and profile
- Agents still need testing to check they cannot be tricked into reading out-of-scope data or changing records
Quotes
- “We have to assume that if the Agent can do something the agent will do that thing. It is like Murphy’s Law.” (Justifies implementing least-privilege security design where agents get only minimum necessary permissions)
- “Even with all this effort, you must still test your agents. Can they be tricked into misbehaving? Can it access out of scope data?” (Emphasizes that security implementation must be verified through comprehensive testing to catch vulnerabilities)
AL objects mentioned
As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.
- codeunit “ARD_CashFlowAgentSetup”
- codeunit “ARD_CashFlowAgentMetadata”
- codeunit “ARD_CashFlowAgentKPILogging”
- codeunit “ARD_CashFlowAgentFactory”
- page “ARD_CashFlowAgentRoleCenter”
- page “ARD_Cash Flow Agent Setup”
- page “ARD_Cash Flow Agent KPI”
- page 22 “Customer List”
- page 27 “Vendor List”
- page 5237 “Employee Ledger Entries”
- table “ARD_CashFlowAgentKPI”
- table “ARD_CashflowAgentSetup”
- table 18 “Customer”
- table 23 “Vendor”
- table 5222 “Employee Ledger Entry”
- permissionset “ARD_CashFlowAgent”
Not found in BC28-30: codeunit “ARD_CashFlowAgentSetup”, codeunit “ARD_CashFlowAgentMetadata”, codeunit “ARD_CashFlowAgentKPILogging”, codeunit “ARD_CashFlowAgentFactory”, page “ARD_CashFlowAgentRoleCenter”, page “ARD_Cash Flow Agent Setup”, page “ARD_Cash Flow Agent KPI”, table “ARD_CashFlowAgentKPI”, table “ARD_CashflowAgentSetup”, permissionset “ARD_CashFlowAgent”.
Possibly related
No source states these links: they share an object, a model read them, or a person found the same subject.
- 👥 Human Resources Module in Business Central🚀 — possibly related: both name Page 5237 “Employee Ledger Entries”
- 🕐 Remember When Lists Could Sort By Any Key? 🔄 — possibly related: both name Page 22 “Customer List”
- All new goodies about AL Namespace in BC 2025 wave 2 — possibly related: both name Page 22 “Customer List”
- Business Central v29: System Audit Fields Now Available in Analysis Mode — possibly related: both name Page 22 “Customer List”
- Dynamics 365 Business Central: Convert Word (.docx) To PDF (.pdf) within BC (No control add-in and APIs) — possibly related: both name Page 22 “Customer List”
- Dynamics 365 Business Central: How to add a new menu to the Role Center — possibly related: both name Page 27 “Vendor List”
- Dynamics 365 Business Central: How to get current Profile (Role) info (Profile ID, Display Name, Source, Role Center ID, etc.) via AL — possibly related: both name Page 22 “Customer List”
- Dynamics 365 Business Central: How to hide/disable New, Edit (Edit List), and Delete actions on the page — possibly related: both name Page 22 “Customer List”
- Dynamics 365 Business Central: How to quickly check whether the user has write (Insert, Delete, and Modify) permission for the table in AL — possibly related: both name Table 23 “Vendor”
- Dynamics 365 Business Central: How to quickly get User Experience/Experience Tier (Essential or Premium) in AL — possibly related: both name Page 22 “Customer List”
Heads up
- warning: “users interact with the Agent. They can make additional requests and inject instructions into the process.”
Context
- Features: agent permissions, profile restrictions, page customizations, role centers, permission sets, data access scoping, least privilege access
Source: Aardvark Labs, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.