<@U04UQ68083H> I am using a code-based method to l...
# ory-copilot
a
@chilly-king-10285 I am using a code-based method to log in to a user. My question is: if I generate a new session and submit the login flow, will it create a new code each time, repeating this cycle indefinitely? Is there a way to limit this? This could allow users to abuse the SMS system and send sms forever
b
A message from kapa.ai
You raise an important security concern about potential abuse of the code-based login method in Ory Identities. Based on the knowledge sources, there isn't explicit documentation about rate limiting for code generation specifically. However, there are some relevant security considerations that address similar concerns: 1. There's an open GitHub issue (#3037) discussing the need for "Throttling repeated login requests & account lock" which proposes implementing rate limiting for login attempts, including exponential backoff between requests and account locking after a specific number of failed attempts [Throttling repeated login requests & account lock](https://github.com/ory/kratos/issues/3037). 2. Another GitHub issue (#4052) discusses appropriate HTTP status codes for login code requests, including using
429 Too Many Requests
when a user attempts to log in too many times within a short period, which suggests rate limiting is being considered [Requesting a login code returns HTTP 400](https://github.com/ory/kratos/issues/4052). 3. The documentation acknowledges security concerns with SMS-based authentication, noting that it's "banned in many government agencies and enterprises due to its security vulnerabilities" [Login and authentication in 2023 explained](https://www.ory.sh/blog/overview-login-password-passkey-webauthn-totp-sso-faceid). While the knowledge sources don't provide a definitive answer about whether Ory currently implements rate limiting for code generation, the open issues suggest this is a recognized concern that's being addressed. If you're concerned about potential abuse, you might want to: 1. Implement your own rate limiting at the application level 2. Monitor the progress of the open issues related to rate limiting 3. Consider using alternative authentication methods that Ory provides, such as passwordless with passkeys or TOTP For the most current information, you may want to check the latest Ory documentation or reach out to Ory support directly.