v0.14 is out: a mobile auth pack for Swift/iOS and Android, catching insecure token storage, cleartext traffic, and OAuth in embedded WebViews. Read more →
MEDIUM AI PREVALENCE: MEDIUM auth.csharp.flow.open-redirect

A redirect target comes straight from user input (a query-string value or a returnUrl-style parameter) and is passed to Redirect(...) without a local-URL check.

Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.

Why this matters

An attacker can craft a link that bounces the victim to an external phishing site after login, and this is the classic OAuth/OIDC returnUrl open-redirect (CWE-601).

Validate the target before redirecting: use Url.IsLocalUrl(returnUrl) (or LocalRedirect(returnUrl), which throws on a non-local URL) so only same-application paths are allowed.

VULNERABLE
vulnerable.cs
using Microsoft.AspNetCore.Mvc;

public class AccountController : Controller
{
    public IActionResult LoginCallback(string returnUrl)
    {
        // ruleid: auth.csharp.flow.open-redirect
        return Redirect(returnUrl);
    }

    public IActionResult Back()
    {
        // ruleid: auth.csharp.flow.open-redirect
        return Redirect(Request.Query["next"]);
    }
}
SAFE
safe.cs
using Microsoft.AspNetCore.Mvc;

public class AccountController : Controller
{
    public IActionResult LoginCallback(string returnUrl)
    {
        // ok: local-URL check before redirecting
        if (Url.IsLocalUrl(returnUrl))
        {
            return Redirect(returnUrl);
        }
        return RedirectToAction("Index", "Home");
    }

    // ok: LocalRedirect throws on a non-local URL
    public IActionResult Safe(string returnUrl)
    {
        return LocalRedirect(returnUrl);
    }
}

Suppressing this rule

If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.

// oauthlint-disable-next-line auth.csharp.flow.open-redirect -- <reason>

References

https://learn.microsoft.com/aspnet/core/security/preventing-open-redirects ↗https://cwe.mitre.org/data/definitions/601.html ↗