Skip to content
BloquestLow-code certifications
← All articles

SQL Injection in OutSystems: Expand Inline and EncodeSql

Published November 11, 2026 · 3 min read

OutSystems protects against SQL Injection by default. Even so, it keeps showing up in real apps, almost always because of a single property: Expand Inline. This article shows when the risk appears and how to close the door.

The situation

An orders app has a search by customer code built with an Advanced SQL query. To "make it easier", the developer turned on Expand Inline for the code parameter. Someone types ' OR 1 = 1 -- in the search field, and the screen starts listing every customer's orders.

The attack in one sentence

SQL Injection happens when untrusted data goes into a query and is interpreted as part of the SQL. With OR 1 = 1, the condition is always true and the query returns everything. With other snippets, the attacker can read, change or delete data.

The protection that comes built in

OutSystems runs queries as prepared statements: each parameter becomes an SQL parameter, which holds only a typed value, never a piece of SQL. This applies to:

  • every Aggregate;
  • Advanced SQL parameters with Expand Inline turned off, which is the default.

In other words: if you hadn't turned on Expand Inline, the search in the example would work with a regular parameter and be protected.

Expand Inline turns the protection off

With Expand Inline on, the parameter value is pasted into the SQL text, bypassing the parameter mechanism. It's useful for building dynamic SQL, but it opens the door to injection.

Service Studio warns you: TrueChange shows the SQL Injection Warning whenever a parameter has Expand Inline on. Double-click the warning to jump to the parameter. Only hide the warning when you're sure the value does not come from the user; hiding it fixes nothing.

If you really need Expand Inline

  1. First, try to avoid it. The documentation shows how to handle common cases (optional filters, sorting, lists) without turning it on.
  2. For text, pass the value through EncodeSql() and wrap it in single quotes: "'" + EncodeSql(CustomerCode) + "'". The function escapes characters like the single quote; without the surrounding quotes, it doesn't protect.
  3. For IN lists, use BuildSafe_InClauseIntegerList or BuildSafe_InClauseTextList, from the Sanitization extension.
  4. For non-text values, or for extra assurance, use VerifySqlLiteral(), which rejects values with reserved SQL characters.

In the example, the simplest fix is to turn Expand Inline off: an equality filter works perfectly with a regular parameter.

What about ODC?

ODC also uses parameterized queries and offers equivalent encoding functions. The rule is the same: don't put user text directly into SQL.

How it shows up in the exam

SQL Injection belongs to the "Other OWASP Vulnerabilities" area, in the XSS and Injection group, worth 2 questions. The traps:

  • Aggregates are already parameterized. The risk is in Advanced SQL with Expand Inline.
  • EncodeSql() without surrounding single quotes doesn't protect.
  • Hiding the SQL Injection Warning fixes nothing.
  • Validating on the client isn't enough, because the attacker calls the server directly (see hiding a button is not protecting it).

Try it in your environment

  1. Open TrueChange in a module with Advanced SQL and look for SQL Injection Warnings.
  2. For each one, check whether the value comes from the user. If it does, try turning Expand Inline off; if you can't, apply EncodeSql with quotes or BuildSafe_InClause….
  3. Test the field with ' OR 1 = 1 -- and confirm nothing extra shows up.

More exam topics in Security Specialist: what the exam is like and how to study.

Bloquest is independent and not affiliated with OutSystems.

Study for your certification by playing

Create your free Bloquest account and start with the first 3 lessons of any course.