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"] 

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>(); 

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(); 

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; }); 

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(); 

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); 

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'); } 

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(); 

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; } 

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; } 

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)); } 

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 

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); 

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"); 

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))); 

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>(); } 

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, th...