bcgov / bcgov/crt

VULN-004 — LINQ Injection via Unsanitised Sort Parameters

Open
#549 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2
Forks
8
PR merge metrics
No merged PRs in 30d

Description

VULN-004 — LINQ Injection via Unsanitised Sort Parameters


Field | Value
-- | --
ID | VULN-004
Severity | High
Category | Injection (LINQ / ORM)
Location | api/Crt.Data/Repositories/Base/CrpRepositoryBase.cs, line 169
OWASP | A03:2021 – Injection
CWE | CWE-89 – SQL Injection (analogous at ORM level)

Evidence:

// api/Crt.Data/Repositories/Base/CrpRepositoryBase.cs, line 169

var pagedList = list.DynamicOrderBy($"{orderBy} {direction}") as IQueryable<TInput>;

// api/Crt.Data/IQueryableDynamicExtensions.cs
return source.OrderBy(ordering, args); // System.Linq.Dynamic.Core — executes ordering string

Description: The orderBy and direction HTTP query parameters are interpolated into a System.Linq.Dynamic.Core expression string without any allowlist check. Dynamic LINQ can execute arbitrary expressions including method calls and property access not intended to be exposed. Every paginated endpoint is affected.

Impact: An authenticated attacker can craft orderBy values to access unexpected entity properties, disclose schema information, or trigger errors that reveal internal data structures.

Recommendation: Validate orderBy and direction against per-entity allowlists before calling DynamicOrderBy. Reject or default-replace any value not on the allowlist.


Contributor guide

No contributing guide indexed for this repository

Research direction

Start with api/Crt.Data/Repositories/Base/CrpRepositoryBase.cs at line 169 and follow DynamicOrderBy into api/Crt.Data/IQueryableDynamicExtensions.cs. Trace how the HTTP orderBy and direction values reach System.Linq.Dynamic.Core, then identify existing tests or request entry points for sorting. Done means arbitrary ordering expressions are no longer accepted while supported sorting still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.