[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79NSKD0A5QPF4CM4B1DH786":3,"skill-same:01M79NSKD0A5QPF4CM4B1DH786":43},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":13,"repositoryHtmlUrl":25,"repositoryHomepageUrl":6,"ownerHtmlUrl":26,"ownerBlogUrl":6,"ownerDescription":27,"updatedAt":28,"install":29,"resources":42},"01M79NSKD0A5QPF4CM4B1DH786","forgot-password-cheat-sheet",null,"JunMystery\u002FAgent-Guidance","JunMystery","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F161468934?v=4","01M79MTMV8F0BY8NK1A92RA8A0","Jun","01M79MTMWCFBKPHN5B25E6V20B",0,"MIT","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fforgot-password-cheat-sheet\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"# Forgot Password Cheat Sheet\n\n## Introduction\n\nIn order to implement a proper user management system, systems integrate a **Forgot Password** service that allows the user to request a password reset.\n\nEven though this functionality looks straightforward and easy to implement, it is a common source of vulnerabilities, such as the renowned [user enumeration attack](https:\u002F\u002Fowasp.org\u002Fwww-project-web-security-testing-guide\u002Fstable\u002F4-Web_Application_Security_Testing\u002F03-Identity_Management_Testing\u002F04-Testing_for_Account_Enumeration_and_Guessable_User_Account.html).\n\nThe following short guidelines can be used as a quick reference to protect the forgot password service:\n\n- **Return a consistent message for both existent and non-existent accounts.**\n- **Ensure that the time taken for the user response message is uniform.**\n- **Use a side-channel to communicate the method to reset their password.**\n- **Use [URL tokens](#url-tokens) for the simplest and fastest implementation.**\n- **Ensure that generated tokens or codes are:**\n    - **Randomly generated using a cryptographically safe algorithm.**\n    - **Sufficiently long to protect against brute-force attacks.**\n    - **Stored securely.**\n    - **Single use and expire after an appropriate period.**\n- **Do not make a change to the account until a valid token is presented, such as locking out the account.**\n\nThis cheat sheet is focused on resetting users passwords. For guidance on resetting multifactor authentication (MFA), see the relevant section in the [Multifactor Authentication Cheat Sheet](Multifactor_Authentication_Cheat_Sheet.md#resetting-mfa).\n\n## Forgot Password Service\n\nThe password reset process can be broken into two main steps, detailed in the following sections.\n\n### Forgot Password Request\n\nWhen a user uses the forgot password service and inputs their username or email, the below should be followed to implement a secure process:\n\n- Return a consistent message for both existent and non-existent accounts.\n- Ensure that responses return in a consistent amount of time to prevent an attacker enumerating which accounts exist. This could be achieved by using asynchronous calls or by making sure that the same logic is followed, instead of using a quick exit method.\n- Implement protections against excessive automated submissions such as rate-limiting on a per-account basis, requiring a CAPTCHA, or other controls. Otherwise an attacker could make thousands of password reset requests per hour for a given account, flooding the user's intake system (e.g., email inbox or SMS) with useless requests.\n- Employ normal security measures, such as [SQL Injection Prevention methods](SQL_Injection_Prevention_Cheat_Sheet.md) and [Input Validation](Input_Validation_Cheat_Sheet.md).\n\n### User Resets Password\n\nOnce the user has proved their identity by providing the token (sent via an email) or code (sent via SMS or other mechanisms), they should reset their password to a new secure one. In order to secure this step, the measures that should be taken are:\n\n- The user should confirm the password they set by writing it twice.\n- Ensure that a secure password policy is in place, and is consistent with the rest of the application.\n- Update and store the password following [secure practices](Password_Storage_Cheat_Sheet.md).\n- Send the user an email informing them that their password has been reset (do not send the password in the email!).\n- Once they have set their new password, the user should then login through the usual mechanism. Don't automatically log the user in, as this introduces additional complexity to the authentication and session handling code, and increases the likelihood of introducing vulnerabilities.\n- Ask the user if they want to invalidate all of their existing sessions, or invalidate the sessions automatically.\n\n### Account Recovery After Suspected Compromise\n\nA password reset alone may not restore control of a compromised account. An attacker may still have an active session or may have changed recovery information or MFA methods.\n\nWhen recovering a potentially compromised account:\n\n- Do not rely solely on recently added or changed recovery information. Use independent, previously established recovery evidence, such as saved recovery codes, in a combination that meets the account's assurance requirements. See [NIST account recovery guidance](https:\u002F\u002Fpages.nist.gov\u002F800-63-4\u002Fsp800-63b\u002Fevents\u002F#recovery).\n- Do not automatically restore superseded recovery addresses or phone numbers; they may have been replaced because they were lost or compromised.\n- Promptly suspend or invalidate authenticators identified as compromised, following [NIST guidance for compromised authenticators](https:\u002F\u002Fpages.nist.gov\u002F800-63-4\u002Fsp800-63b\u002Fevents\u002F#loss-theft-damage-and-compromise).\n- Review recovery addresses, phone numbers, and MFA methods with the verified account owner, and remove unauthorized changes. [Google's compromised-account guidance](https:\u002F\u002Fsupport.google.com\u002Faccounts\u002Fanswer\u002F6294825) identifies these settings for review and correction.\n- After successful recovery, invalidate existing sessions and outstanding password reset and recovery links or codes so they cannot restore an attacker's access. See [session invalidation guidance](Session_Management_Cheat_Sheet.md#session-expiration).\n- Notify the user through all applicable registered notification addresses, including established channels that remain safe to use. Include instructions and contact information for reporting unauthorized recovery, as described in [NIST account notification guidance](https:\u002F\u002Fpages.nist.gov\u002F800-63-4\u002Fsp800-63b\u002Fevents\u002F#notification).\n\nSee [reauthentication after risk events](Authentication_Cheat_Sheet.md#re-authentication-after-risk-events) and [MFA recovery](Multifactor_Authentication_Cheat_Sheet.md#resetting-mfa) for related controls.\n\n## Methods\n\nIn order to allow a user to request a password reset, you will need to have some way to identify the user, or a means to reach out to them through a side-channel.\n\nThis can be done through any of the following methods:\n\n- [URL tokens](#url-tokens).\n- [PINs](#pins)\n- [Offline methods](#offline-methods)\n- [Security questions](#security-questions).\n\nThese methods can be used together to provide a greater degree of assurance that the user is who they claim to be. No matter what, you must ensure that a user always has a way to recover their account, even if that involves contacting the support team and proving their identity to staff.\n\n### General Security Practices\n\nIt is essential to employ good security practices for the reset identifiers (tokens, codes, PINs, etc.). Some points don't apply to the [offline methods](#offline-methods), such as the lifetime restriction. All tokens and codes should be:\n\n- Generated using a [cryptographically secure random number generator](Cryptographic_Storage_Cheat_Sheet.md#secure-random-number-generation).\n    - It is also possible to use JSON Web Tokens (JWTs) in place of random tokens, although this can introduce additional vulnerability, such as those discussed in the [JSON Web Token Cheat Sheet](JSON_Web_Token_Cheat_Sheet.md).\n- Long enough to protect against brute-force attacks.\n- Linked to an individual user in the database.\n- Invalidated after they have been used.\n- Stored in a secure manner, as discussed in the [Password Storage Cheat Sheet](Password_Storage_Cheat_Sheet.md).\n\n### URL Tokens\n\nURL tokens are passed in the query string of the URL, and are typically sent to the user via email. The basic overview of the process is as follows:\n\n1. Generate a token for the user and attach it in the URL query string.\n2. Send this token to the user via email.\n   - Don't rely on the [Host](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FHTTP\u002FHeaders\u002FHost) header while creating the reset URLs to avoid [Host Header Injection](https:\u002F\u002Fowasp.org\u002Fwww-project-web-security-testing-guide\u002Fstable\u002F4-Web_Application_Security_Testing\u002F07-Input_Validation_Testing\u002F17-Testing_for_Host_Header_Injection) attacks. The URL should either be hard-coded, or validated against a list of trusted domains.\n   - Ensure that the URL is using HTTPS.\n3. The user receives the email, and browses to the URL with the attached token.\n   - Ensure that the reset password page adds the [Referrer Policy](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FHTTP\u002FHeaders\u002FReferrer-Policy) tag with the `no-referrer` value in order to avoid [referrer leakage](https:\u002F\u002Fportswigger.net\u002Fkb\u002Fissues\u002F00500400_cross-domain-referer-leakage).\n   - Implement appropriate protection to prevent users from brute-forcing tokens in the URL, such as rate limiting.\n4. If required, perform any additional validation steps such as requiring the user to answer [security questions](#security-questions).\n5. Let the user create a new password and confirm it. Ensure that the same password policy used elsewhere in the application is applied.\n\n*Note:* URL tokens can follow on the same behavior of the [PINs](#pins) by creating a restricted session from the token. Decision should be made based on the needs and the expertise of the developer.\n\n### PINs\n\nPINs are numbers (between 6 and 12 digits) that are sent to the user through a side-channel such as SMS.\n\n1. Generate a PIN.\n2. Send it to the user via SMS or another mechanism.\n   - Breaking the PIN up with spaces makes it easier for the user to read and enter.\n3. The user then enters the PIN along with their username on the password reset page.\n4. Create a limited session from that PIN that only permits the user to reset their password.\n5. Let the user create a new password and confirm it. Ensure that the same password policy used elsewhere in the application is applied.\n\n### Offline Methods\n\nOffline methods differ from other methods by allowing the user to reset their password without requesting a special identifier (such as a token or PIN) from the backend. However, authentication still needs to be conducted by the backend to ensure that the request is legitimate. Offline methods provide a certain identifier either on registration, or when the user wishes to configure it.\n\nThese identifiers should be stored offline and in a secure fashion (*e.g.* password managers), and the backend should properly follow the [general security practices](#general-security-practices). Some implementations are built on [hardware OTP tokens](Multifactor_Authentication_Cheat_Sheet.md#hardware-otp-tokens), [certificates](Multifactor_Authentication_Cheat_Sheet.md#certificates), or any other implementation that could be used inside of an enterprise. These are out of scope for this cheat sheet.\n\nIf account has MFA enabled, and you are looking for MFA recovery, different methods can be found in the corresponding [Multifactor Authentication cheat sheet](Multifactor_Authentication_Cheat_Sheet.md#resetting-mfa).\n\n### Security Questions\n\nSecurity questions should not be used as the sole mechanism for resetting passwords due to their answers frequently being easily guessable or obtainable by attackers. However, they can provide an additional layer of security when combined with the other methods discussed in this cheat sheet. If they are used, then ensure that secure questions are chosen as discussed in the [Security Questions cheat sheet](Choosing_and_Using_Security_Questions_Cheat_Sheet.md).\n\n## Account Lockout\n\nAccounts should not be locked out in response to a forgotten password attack, as this can be used to deny access to users with known usernames. For more details on account lockouts, see the [Authentication Cheat Sheet](Authentication_Cheat_Sheet.md).\n\n## References\n\n- [NIST SP 800-63B-4: Account Recovery](https:\u002F\u002Fpages.nist.gov\u002F800-63-4\u002Fsp800-63b\u002Fevents\u002F#recovery)\n- [OWASP Application Security Verification Standard (ASVS): V6.4 Authentication Factor Lifecycle and Recovery](https:\u002F\u002Fgithub.com\u002FOWASP\u002FASVS\u002Fblob\u002Fmaster\u002F5.0\u002Fen\u002F0x15-V6-Authentication.md#v64-authentication-factor-lifecycle-and-recovery)\n",{},"main","5d0a87185c0e172c3901e2a6e5916b6d544b8b94","skills\u002Fforgot-password-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance","https:\u002F\u002Fgithub.com\u002FJunMystery","AI is the typist, I am the architect. Building efficient, secure, and user-centric products through disciplined AI prompt engineering.","2026-11-13 17:41:25",{"source":7,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add JunMystery\u002FAgent-Guidance --skill forgot-password-cheat-sheet",{"tool":35,"command":36},"bunx","bunx skills add JunMystery\u002FAgent-Guidance --skill forgot-password-cheat-sheet",{"tool":38,"command":39},"pnpm","pnpm dlx skills add JunMystery\u002FAgent-Guidance --skill forgot-password-cheat-sheet","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fforgot-password-cheat-sheet\u002FSKILL.md",true,[],[44,50,56,62,68,74],{"skillNo":45,"name":46,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":47,"categories":48,"keywords":49,"publishedAt":18},"01M79QR1E309VJ6CTQKB32AWWA","zero-trust-architecture-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-architecture-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":51,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M79QQV7GHYR02DYGN41S23WN","xss-filter-evasion-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxss-filter-evasion-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M79QQNSN7YB8XB61FFSCS3WH","xs-leaks-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxs-leaks-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M79QQHZZJKFDY9132G5A65C2","xpath-injection-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxpath-injection-prevention-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M79QQB9ZSD3DJG8658EHQXR1","xml-security-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-security-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M79QQ60WKV7PFMXWT9CW8PM6","xml-external-entity-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-external-entity-prevention-cheat-sheet\u002FSKILL.md",[],[]]