Safeguard
Application Security•

ASVS 5.0 V8.2.4: Adaptive Controls Based on Context

ASVS V8.2.4 (Level 3) wants authentication and authorization decisions to react to time, location, IP and device, at login and during the session.

Safeguard Security Team
2 min read

ASVS 5.0 V8.2.4 asks for adaptive security controls: decisions that change based on a consumer's context, such as time of day, location, IP address or device. It is Level 3, so it targets high-assurance systems. The controls must apply when a session starts and again during the session, and they must match what your documentation says.

Why it matters

A valid password or token proves little about who is holding it. A session cookie replayed from another continent twenty minutes after the real login looks identical to the original until you compare context.

How to implement it

Write down the rules first. The standard says the controls are "as defined in the application's documentation", so a documented policy is part of the requirement.

At login, score the attempt. At each sensitive request, re-score it against the session's baseline.

def evaluate(session, request):
    signals = {
        "new_device": request.device_id not in session.known_devices,
        "ip_changed": request.ip_prefix != session.ip_prefix,
        "geo_jump": distance_km(session.geo, request.geo) > 1000,
        "off_hours": not within_working_hours(session.user, request.time),
    }
    score = sum(signals.values())
    if score >= 3:
        return "deny"
    if score >= 1 and request.is_sensitive:
        return "step_up"   # require a fresh MFA challenge
    return "allow"

Log every non-allow decision with the signals that caused it.

How to test it

Replay one session cookie from a different IP and user agent and confirm the step up or deny result. Use a VPN to simulate a geo jump. Run a sensitive action outside the documented hours. Confirm the same rules fire mid-session, not only at login.

Common mistakes

  • Checking context only at login.
  • Trusting X-Forwarded-For from any client.
  • Hard blocking on weak signals, which locks out travelers and teaches users to ignore alerts.
  • Having rules that exist in code but nowhere in documentation.

Quick check

Is a login time check enough for V8.2.4?

No. The requirement covers both session start and the existing session.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.