Slow Down Online Guessing Attacks with Device Cookies

Patient Tools

Read, save, and share this guide

Use these quick tools to make this medical article easier to read, print, save, or share with a family member.

Article Summary

Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at PasswordsCon 14. Marc speculates on various techniques for blocking online attacks and comes to notion of "device cookie" as good protection alternative (see the talk on Hydra at PasswordsCon 14, specifically from 32:50). As well as Alec Muffett at the...

Key Takeaways

  • This article explains Why? in simple medical language.
  • This article explains Protocol in simple medical language.
  • This article explains Implementation Tips in simple medical language.
  • This article explains Threat Analysis in simple medical language.
Educational health guideWritten for patient understanding and clinical awareness.
Reviewed content workflowUse writer and reviewer profiles for stronger trust.
Emergency safety firstUrgent warning signs are highlighted below.

Seek urgent medical care if you notice

These warning signs are general safety guidance. Local emergency numbers and clinical judgment should always come first.

  • Severe symptoms, breathing difficulty, fainting, confusion, or rapidly worsening illness.
  • New weakness, severe pain, high fever, or symptoms after a serious injury.
  • Any symptom that feels urgent, unusual, or unsafe for the patient.
1

Emergency now

Use emergency care for severe, sudden, rapidly worsening, or life-threatening symptoms.

2

See a doctor

Book a professional medical evaluation if symptoms persist, worsen, recur often, affect daily activities, or occur in a high-risk patient.

3

Learn safely

Use this article to understand possible causes, tests, treatment options, prevention, and questions to ask your clinician.

Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at PasswordsCon 14.

Marc speculates on various techniques for blocking online attacks and comes to notion of “device cookie” as good protection alternative (see the talk on Hydra at PasswordsCon 14, specifically from 32:50). As well as Alec Muffett at the same conference mentions “datr cookie” from Facebook (look from 10:15 of the talk).

The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:

  • Distinguish between known/trusted and unknown/untrusted clients
  • Establish universal temporary lockouts for all untrusted clients
  • Lockout trusted clients individually

Why?

There are few well-known ways to deal with online attacks:

  • Temporary account lockout
  • Use CAPTCHA to slow down attacker

Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.

Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:

  • Attacks from botnets can be effective
  • Attacks through proxies can be effective

Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.

The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.

Protocol

Protocol parameters:

  • T – Time period for lockout duration/attempt counting
  • N – Max number of failed authentication attempts allowed during T

The sign ∎ hereafter states for end of algorithm.

Entry point for authentication request

  1. If the incoming request contains a device cookie:
    1. validate device cookie
    2. if device cookie is invalid, proceed to step 2.
    3. if the device cookie is in the lockout list -> reject authentication attempt ∎
    4. else -> authenticate user
  2. If authentication from untrusted clients is locked out for this user -> reject authentication attempt ∎
  3. Else -> authenticate user ∎

Authenticate user

  1. Check user credentials
  2. If credentials are valid
    1. issue new device cookie to user’s client
    2. proceed with authenticated user
  3. Else
    1. register failed authentication attempt
    2. reject authentication attempt ∎

Register failed authentication attempt

  1. Register a failed authentication attempt with following information: { user, time, device cookie (if present) }
  2. If device cookie is present
    1. count number of failed authentication attempts within time period T for this specific cookie
    2. if number of failed attempts within T > N -> put device cookie in lockout list until now() + T
  3. Else (= no device cookie present)
    1. count number of all failed authentication attempts for this user during time period T
    2. if number of failed attempts within T > N -> lockout ALL authentication attempts from untrusted clients for this specific user until now() + T

Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where:

  • LOGIN – User’s login name (or internal ID) corresponding to an authenticated user
  • NONCE – Nonce of sufficient length or random value from CSRNG source
  • SIGNATURE – HMAC(secret-key, “LOGIN,NONCE”)
  • secret-key – server’s secret cryptographic key
  1. Validate that the device cookie is formatted as described above
  2. Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)
  3. Validate that LOGIN represents the user who is actually trying to authenticate

Notes

  • Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make N * 2 failed authentication attempts before actual lockout.
  • Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like:

“Should the system block a device cookie if there were registered N-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period T.”

Implementation Tips

It is good idea to use a standard format for device cookies. So, if the size of a cookie is not an issue, it is recommended to use JWT.

The following standard claims can be used:

  • sub – LOGIN
  • jti – NONCE

Important: If you already use JWT for storing session tokens or other security stuff, make sure you cannot confuse device cookies with other types of tokens. There are two possible ways to mitigate this threat:

  1. Use different signature / encryption keys for different token types
  2. Add aud claim into device cookie token that unambiguously refers to brute force protection subsystem (e.g. “aud” : “brute-force-protection” or “device cookie”).

Threat Analysis

Threat

Threat details

Mitigation

Online attack against one user

Attacker performs a guessing attack against a specific account from an untrusted client(s).

As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (N/T)*24h per day.

E.g. for N = 10 and T = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in their possession is.

If there is a good password policy in place that limits minimum number attempts to 106 then the targeted attack will last (on average) 5 years.

Online attack using stolen device cookies

Attacker performs long-running guessing attack against specific account(s) from known clients.

Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra N attempts per T for specific user.

There may be two ways to steal device cookies:

  • Using physical access to a known client
  • Active attack against a remote client

In both cases if the attacker can steal device cookies on a regular basis they may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use Secure and HttpOnly flags).

Proposal: Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after N*10 failed attempts.

Online attack against multiple users

Attacker performs guessing attack against a specific number of accounts from untrusted clients.

Attacker may try the same password from a long list against many (all) accounts in a system without reaching N failed attempts per account during period T.

There is no specific mitigation for this threat in the protocol.

Good password policy may be a sufficient countermeasure for such attacks.

Additionally an application may temporarily require CAPTCHA solving for authentication from untrusted clients in case there are too many authentication attempts for different accounts during a specified period of time.

Spoof device cookie

Attacker may try to forge a valid device cookie for any user in a system.

Proper crypto implementation: HMAC and random secret key.

Tamper with existing device cookie

Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.

Proper crypto implementation: HMAC and random secret key.

DoS for specific account

Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as they would need to login from a new device or to login after cleaning up their browser cache.

Issue a valid device cookie after visiting password reset link (an actual password reset is not necessary). Thus, if the user demonstrates their possession of a personal email account then the system may trust a client to try entering their credentials.

DoS for specific account when client is used by different accounts

There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.

Cases where the same client is shared between legitimate users may be considered out of scope by default.

If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly.

Patient safety assistant

Check your symptom safely

Hi, I am RX Symptom Navigator. I can help you understand what to read next and what warning signs need care.
Warning: Do not use this in emergencies, pregnancy, severe illness, or as a substitute for a doctor. For children or teens, use with a parent/guardian and clinician.
A rural-friendly guide: warning signs, when to see a doctor, related articles, tests to discuss, and OTC safety education.
1 Symptom 2 Severity 3 Safe guidance
First safety question

Is there chest pain, breathing trouble, fainting, confusion, severe bleeding, stroke-like weakness, severe injury, or pregnancy danger sign?

Choose quickly

Browse by body area
Start here: Write or select a symptom. The guide will show warning signs, doctor guidance, diagnostic tests to discuss, OTC safety education, and related RX articles.

Important: This tool is educational only. It cannot diagnose, treat, or replace a doctor. OTC information is not a prescription. In an emergency, contact local emergency services or go to the nearest hospital.

Doctor visit helper

Prepare before seeing a doctor

A simple rural-patient checklist to help you explain symptoms clearly, ask better questions, and avoid unsafe self-treatment.

Safety note: This is not a prescription or diagnosis. For severe symptoms, pregnancy danger signs, children with serious illness, chest pain, breathing difficulty, stroke-like weakness, or major injury, seek urgent care.

Which doctor may help?

Start with a registered doctor or the nearest qualified health center.

What to tell the doctor

  • Write when the problem started and how it changed.
  • Bring old prescriptions, investigation reports, and current medicines.
  • Write allergies, pregnancy status, diabetes, kidney/liver disease, and major past illnesses.
  • Bring one family member if the patient is weak, elderly, confused, or a child.

Questions to ask

  • What is the most likely cause of my symptoms?
  • Which danger signs mean I should go to hospital quickly?
  • Which tests are necessary now, and which can wait?
  • How should I take medicines safely and what side effects should I watch for?
  • When should I come for follow-up?

Tests to discuss

  • Vital signs: temperature, pulse, blood pressure, oxygen saturation
  • Basic physical examination by a clinician
  • CBC, urine test, blood sugar, or imaging only when clinically needed

Avoid these mistakes

  • Do not use antibiotics, steroid tablets/injections, or strong painkillers without proper medical advice.
  • Do not hide pregnancy, kidney disease, ulcer, allergy, or blood thinner use.
  • Do not delay emergency care when danger signs are present.

Medicine safety and first-aid guide

This section is for patient education only. It does not replace a doctor, pharmacist, or emergency care.

Safe first steps

  • Avoid heavy lifting, sudden bending, and prolonged bed rest.
  • Use comfortable posture and gentle movement as tolerated.
  • Discuss physiotherapy, X-ray, or MRI only when clinically needed.

OTC medicine safety

  • For mild back pain, pain-relief medicine may be discussed with a doctor or pharmacist.
  • Avoid repeated painkiller use if you have kidney disease, stomach ulcer, uncontrolled blood pressure, or are taking blood thinners.

Avoid these mistakes

  • Do not start antibiotics without a proper medical decision.
  • Do not use steroid tablets or injections casually for quick relief.
  • Do not delay emergency care because of home remedies.

Get urgent help if

  • Back pain with leg weakness, numbness around private area, loss of urine/stool control, fever, cancer history, or major injury needs urgent care.
Medicine names, dose, and timing must be decided by a qualified clinician or pharmacist after checking age, pregnancy, allergy, other diseases, and current medicines.

For rural patients and family caregivers

Patient health record and symptom diary

Write your symptoms, medicines already taken, test results, and questions before visiting a doctor. This note stays on your device unless you print or copy it.

Doctor to discuss: Doctor / qualified healthcare provider
Tests to discuss with doctor
  • Basic vital signs: temperature, pulse, blood pressure, oxygen level if needed
  • Relevant blood, urine, imaging, or specialist tests only after clinical assessment
Questions to ask
  • What is the most likely cause of my symptoms?
  • Which warning signs mean I should go to emergency care?
  • Which tests are really needed now?
  • Which medicines are safe for my age, pregnancy status, allergy, kidney/liver/stomach condition, and current medicines?

Emergency warning signs such as chest pain, severe breathing difficulty, sudden weakness, confusion, severe dehydration, major injury, or loss of bladder/bowel control need urgent medical care. Do not wait for online information.

Safe pathway to proper treatment

Back pain care roadmap

Use this simple roadmap to understand the next safe steps. It is educational and does not replace examination by a doctor.

Go to emergency care if you notice:
  • New leg weakness, numbness around private area, or loss of bladder/bowel control
  • Back pain after major injury, fever, unexplained weight loss, cancer history, or severe night pain
Doctor / service to discuss: Orthopedic/spine specialist, physical medicine doctor, physiotherapist under guidance, or qualified clinician.
  1. Step 1

    Check danger signs first

    If danger signs are present, seek emergency care and do not wait for online information.

  2. Step 2

    Record the symptom story

    Write when symptoms started, severity, medicines already taken, allergies, pregnancy status, and test results.

  3. Step 3

    Visit a qualified clinician

    A doctor, nurse, or qualified healthcare provider can examine you and decide which tests or treatment are needed.

  4. Step 4

    Do only useful tests

    Discuss neurological examination first. X-ray or MRI may be needed only when red flags, injury, nerve weakness, or persistent severe symptoms are present.

  5. Step 5

    Follow up and return early if worse

    If symptoms worsen, new warning signs appear, or treatment is not helping, return for review quickly.

Rural patient practical tips
  • Take a written symptom diary and all previous prescriptions/test reports.
  • Do not hide medicines already taken, even herbal or over-the-counter medicines.
  • Ask which warning signs mean urgent referral to hospital.
  • Avoid forceful massage or bone-setting when there is weakness, injury, fever, or nerve symptoms.

This roadmap is for education. A real diagnosis and treatment plan requires history, examination, and clinical judgment.

RX Patient Help

Ask a health question safely

Write your symptom story. A health professional or site editor can review it before any answer is prepared. This box is not for emergency care.

Emergency first: Severe chest pain, breathing trouble, unconsciousness, stroke signs, severe injury, heavy bleeding, or rapidly worsening symptoms need urgent local medical care now.

Frequently Asked Questions

Why?

There are few well-known ways to deal with online attacks: Temporary account lockout Use CAPTCHA to slow down attacker Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism. Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but…

References

Add references, clinical guidelines, textbooks, journal articles, or trusted medical sources here. You can edit this area from the RX Article Professional Blocks panel.