Repository navigation
Description
Summary
Introduce an optional Strict Protection security profile for UltimateAuth.
UltimateAuth currently provides configurable security controls, authentication policies, session management, rate limiting, identifier management, and endpoint-level access restrictions.
These capabilities allow developers to build secure applications while preserving flexibility and developer experience.
However, applications with higher security or privacy requirements may need stronger guarantees than individually configured options can provide.
Strict Protection should establish a coherent, enforceable security contract that applies across authentication, registration, credentials, sessions, tokens, and sensitive endpoints.
The primary objective is to make security-sensitive configuration decisions explicit, prevent unsafe combinations, and reduce the risk of accidental misconfiguration.
Strict Protection must be opt-in and must not change the existing default behavior of UltimateAuth.
Motivation
Security protections are often distributed across multiple independent configuration options.
A developer may correctly configure one security control while unintentionally weakening another.
Examples include:
- Enabling anonymous identifier availability for sensitive identifiers.
- Exposing account existence through registration responses.
- Allowing unnecessarily long-lived access or refresh credentials.
- Disabling important session validation requirements.
- Configuring permissive credential delivery or cookie policies.
- Disabling rate limiting on sensitive authentication operations.
- Allowing authentication credentials to remain valid after critical security events.
- Using incompatible combinations of authentication, session, and client-profile options.
Some risks cannot be eliminated by changing an error message or enabling a single option.
For example, anonymous registration may reveal identifier existence through different success and failure outcomes, even when detailed error messages are disabled.
Strict Protection should address these risks at the appropriate architectural level rather than relying exclusively on response masking.
Proposed design
Introduce a security profile concept, potentially exposed through an API such as:
options.Security.ProtectionLevel = UAuthProtectionLevel.Strict;The exact public API and naming should be determined during implementation.
The profile should:
- Apply stronger security defaults.
- Enforce mandatory security invariants.
- Validate configuration compatibility at startup.
- Reject unsafe combinations with actionable error messages.
- Preserve the existing default security model when Strict Protection is not enabled.
- Clearly distinguish enforceable guarantees from recommendations and optional hardening controls.
Strict Protection should not simply override every configured value silently.
Where a configuration violates a mandatory security invariant, UltimateAuth should fail fast and explain the conflict.
Candidate protection domains
The following protections are proposals for evaluation, not finalized requirements.
1. Account enumeration and privacy
Reduce account enumeration through authentication, registration, recovery, and identifier management.
Potential requirements:
- Require generic external authentication failure responses.
- Prevent exposure of lockout state, remaining attempts, and internal failure reasons.
- Restrict anonymous availability queries for sensitive identifiers such as email and phone.
- Require explicit handling of public username availability.
- Reject direct anonymous registration configurations that expose sensitive identifier existence unless an enumeration-resistant registration flow is provided.
- Require generic responses for account recovery initiation.
- Avoid exposing user existence through MFA and credential recovery responses.
- Evaluate timing differences and other observable side channels.
- Prevent sensitive identifier information from appearing in redirects, headers, or response metadata.
Strict Protection must not pretend to eliminate enumeration by returning the same HTTP status code while exposing different outcomes elsewhere.
Registration privacy may require a distinct registration initiation and verification workflow. This should be designed separately rather than changing the semantics of the existing direct user creation API.
2. Token lifetime and credential exposure
Limit the damage caused by stolen or leaked credentials.
Potential requirements:
- Enforce maximum access-token lifetimes.
- Enforce maximum refresh-token lifetimes.
- Restrict excessively long-lived authentication credentials.
- Require bounded absolute session lifetimes.
- Evaluate refresh-token rotation and replay detection.
- Prevent unrestricted token renewal.
- Require secure token storage and delivery mechanisms appropriate to the client profile.
- Restrict bearer-token exposure to browser environments where safer delivery mechanisms are available.
- Evaluate token revocation requirements following critical security events.
Token lifetime restrictions should be defined according to credential type and authentication mode.
A short-lived access token does not automatically make an application secure if refresh credentials remain valid indefinitely.
The profile should account for PureOpaque, Hybrid, SemiHybrid, and future authentication modes without assuming that every mode issues JWTs.
3. Session and device security
Strengthen session validation and lifecycle guarantees.
Potential requirements:
- Require device binding where the configured client and device model support it.
- Reject missing required device identifiers.
- Require server-side session revocation capabilities.
- Enforce idle and absolute session expiration.
- Restrict unlimited session lifetime extension.
- Require appropriate session invalidation following password changes, credential resets, or account compromise.
- Evaluate concurrent session limits.
- Require consistent session validation across local and remote Resource APIs.
- Prevent unsafe bypasses of session validation.
- Evaluate whether privileged operations require recent authentication.
Device identifiers must not be treated as cryptographic proof of device possession unless an appropriate cryptographic mechanism exists.
4. Authentication and brute-force protection
Require meaningful resistance against automated credential attacks.
Potential requirements:
- Enforce rate limiting for sensitive authentication endpoints.
- Reject configurations that completely disable mandatory protections without an equivalent alternative.
- Require bounded login attempts or an equivalent adaptive abuse-prevention mechanism.
- Evaluate account-based, identifier-based, IP-based, and distributed attack controls.
- Require safe handling of concurrent authentication attempts.
- Prevent lockout state disclosure.
- Evaluate protections against targeted account lockout denial-of-service.
- Require appropriate password hashing parameters.
- Consider dummy password verification to reduce timing-based enumeration.
Strict Protection should avoid requiring a specific lockout implementation when an alternative provides equivalent security guarantees.
5. CSRF, cookies, and credential delivery
Strengthen browser authentication protections.
Potential requirements:
- Require CSRF protection for applicable cookie-authenticated state-changing operations.
- Prevent unsafe antiforgery bypasses.
- Enforce secure cookie attributes appropriate to the deployment.
- Require HTTPS for production credential delivery.
- Restrict unsafe cross-origin credential configurations.
- Validate trusted origins and client-profile boundaries.
- Prevent unsafe cookie or token delivery combinations.
- Evaluate PKCE requirements for applicable flows.
- Reject incompatible credential delivery and client-profile settings.
The profile must preserve legitimate Blazor Server, Blazor WebAssembly, MAUI, and Resource API scenarios.
6. User lifecycle and authorization
Ensure security-sensitive account states are consistently enforced.
Potential requirements:
- Prevent administratively suspended or disabled users from creating new authenticated sessions.
- Define how suspension affects existing sessions and refresh operations.
- Require consistent account-state enforcement across authentication and authorization.
- Evaluate mandatory revocation following critical account-state transitions.
- Prevent security-sensitive user management actions from bypassing required authorization policies.
- Require appropriate protection for administrative operations.
Suspended, SelfSuspended, and Disabled must retain clearly defined and separately tested semantics.
Strict Protection should not silently break supported account recovery or self-reactivation workflows.
7. Security-sensitive endpoints
Evaluate restrictions for endpoints that expose sensitive information or perform high-impact operations.
Potential requirements:
- Restrict anonymous identifier availability.
- Restrict direct anonymous user creation where privacy guarantees cannot be satisfied.
- Require authentication and authorization for administrative and account-management operations.
- Enforce rate limiting on recovery, verification, registration, and credential endpoints.
- Prevent exposure of internal diagnostic information.
- Reject unsafe endpoint configurations when they conflict with mandatory profile guarantees.
Endpoint restrictions should build on the existing action and DisabledActions architecture rather than introducing a parallel authorization system.
8. Configuration validation and fail-fast behavior
Introduce centralized validation for Strict Protection invariants.
Examples of potential startup failures:
Strict Protection requires generic authentication failures.
Strict Protection does not allow unrestricted token lifetimes.
Strict Protection requires CSRF protection for cookie-based authentication.
Strict Protection does not permit anonymous email availability.
Strict Protection requires a supported registration privacy strategy
when anonymous registration is enabled.
Validation should:
- Run during application startup.
- Identify the exact conflicting option.
- Explain the security requirement.
- Provide actionable remediation guidance.
- Avoid silently modifying explicitly configured unsafe values.
- Be testable independently of the application host.
The final design should distinguish:
- Mandatory invariants that cannot be overridden.
- Configurable values within secure bounds.
- Advisory recommendations that do not prevent startup.
Compatibility and developer experience
Strict Protection should preserve UltimateAuth's developer-experience-first philosophy.
Requirements:
- Existing applications remain unaffected unless the profile is explicitly enabled.
- The normal security configuration remains fully supported.
- Strict Protection must not introduce unnecessary complexity into the standard Quick Start.
- Errors must explain why an option is incompatible.
- Security restrictions should be documented with their functional tradeoffs.
- Legitimate client profiles must remain supported through appropriate security configurations.
- Existing authentication modes should be evaluated individually.
Strict Protection should not be described as making applications completely secure.
It establishes a stronger framework-level security baseline; application-specific authorization, infrastructure security, secret management, monitoring, and operational controls remain the developer's responsibility.
Implementation strategy
Implement incrementally rather than enabling every proposed restriction in a single change.
Suggested phases:
Phase 1 — Security profile foundation
- Define the protection-level API.
- Introduce centralized configuration validation.
- Define mandatory invariants and secure bounds.
- Implement fail-fast diagnostics.
- Preserve default behavior.
Phase 2 — Authentication and privacy
- Enforce generic authentication failures.
- Address indirect account enumeration.
- Define registration privacy requirements.
- Restrict sensitive identifier availability.
- Strengthen recovery response consistency.
Phase 3 — Tokens and sessions
- Enforce credential lifetime limits.
- Strengthen refresh and revocation requirements.
- Enforce session and device validation invariants.
- Evaluate privileged-session requirements.
Phase 4 — Advanced protection
- Evaluate distributed abuse prevention.
- Strengthen concurrent authentication safety.
- Add optional security diagnostics.
- Expand protection coverage as new authentication modes and features are introduced.
Each phase should have its own focused implementation PRs and regression tests.
Acceptance criteria
- An opt-in Strict Protection profile is available.
- Existing default behavior remains unchanged.
- Mandatory security invariants are explicitly documented.
- Conflicting configurations fail during startup with actionable diagnostics.
- Unsafe token and session lifetime configurations are rejected according to defined bounds.
- Authentication failure disclosure is restricted.
- Sensitive identifier enumeration risks are addressed according to a documented privacy contract.
- Anonymous registration behavior does not claim enumeration resistance without an appropriate workflow.
- Applicable CSRF, credential delivery, and session validation requirements are enforced.
- All supported client profiles and authentication modes have documented compatibility expectations.
- Unit and integration tests cover accepted and rejected configurations.
- Documentation explains security guarantees, limitations, and developer-experience tradeoffs.
Out of scope
- Replacing the existing authorization or policy system.
- Requiring every UltimateAuth application to use Strict Protection.
- Guaranteeing complete protection against all account enumeration side channels.
- Implementing a full WAF, bot detection platform, or distributed security infrastructure.
- Replacing application-specific security architecture.
- Implementing every candidate protection in the initial PR.
Design principle
Strict Protection should provide enforceable security guarantees, not merely a collection of recommended settings.
When an application opts into Strict Protection, UltimateAuth should either satisfy the defined security contract or refuse to start with a clear explanation of what must be changed.
Activity