FusionAuth / fusionauth-issues

FusionAuth issue submission project
https://fusionauth.io
91 stars 12 forks source link

Send MFA fails with FreeMarker Error when Rate Limited #2887

Open jobannon opened 1 month ago

jobannon commented 1 month ago

Description

Enable "ATD rate limiting" for Send two-factor action/endpoint. See that we exception on the freemarker template

Observed versions

1.53.0

Affects versions

The version, or versions where this bug exists. If you do not know, please leave blank for now.

Steps to reproduce

Steps to reproduce the behavior:

  1. Enable Send two-factor rate limiting on the security tab of the tenant
  2. Enable MFA for a user
  3. Attempt to login and get MFA prompt as expected
  4. Exceed the rate limit (send multiple SMS and emails for the code) and see this stack trace
Blamed expression: request.requestURI
Line number: 148
Column number: 36
End column number: 53
Theme Id: –
Template name: templates/_helpers.ftl

Message:

The following has evaluated to null or missing:
==> request.requestURI  [in template "templates/_helpers.ftl" at line 148, column 36]

----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use [#if myOptionalVar??]when-present[#else]when-missing[/#if]. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
    - Failed at: #if request.requestURI == "/"  [in template "templates/_helpers.ftl" in macro "header" at line 148, column 31]
    - Reached through: @helpers.header  [in template "templates/oauth2/two-factor-methods.ftl" at line 58, column 5]
    ~ Reached through: #nested  [in template "templates/_helpers.ftl" in macro "body" at line 140, column 3]
    ~ Reached through: @helpers.body  [in template "templates/oauth2/two-factor-methods.ftl" at line 56, column 3]
    ~ Reached through: #nested  [in template "templates/_helpers.ftl" in macro "html" at line 31, column 3]
    ~ Reached through: @helpers.html  [in template "templates/oauth2/two-factor-methods.ftl" at line 52, column 1]
----

FreeMarker template error:
The following has evaluated to null or missing:
==> request.requestURI  [in template "templates/_helpers.ftl" at line 148, column 36]

----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use [#if myOptionalVar??]when-present[#else]when-missing[/#if]. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
    - Failed at: #if request.requestURI == "/"  [in template "templates/_helpers.ftl" in macro "header" at line 148, column 31]
    - Reached through: @helpers.header  [in template "templates/oauth2/two-factor-methods.ftl" at line 58, column 5]
    ~ Reached through: #nested  [in template "templates/_helpers.ftl" in macro "body" at line 140, column 3]
    ~ Reached through: @helpers.body  [in template "templates/oauth2/two-factor-methods.ftl" at line 56, column 3]
    ~ Reached through: #nested  [in template "templates/_helpers.ftl" in macro "html" at line 31, column 3]
    ~ Reached through: @helpers.html  [in template "templates/oauth2/two-factor-methods.ftl" at line 52, column 1]
----

Java stack trace (for programmers):
----
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
    at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)
    at freemarker.core.EvalUtil.compare(EvalUtil.java:199)
    at freemarker.core.EvalUtil.compare(EvalUtil.java:116)
    at freemarker.core.ComparisonExpression.evalToBoolean(ComparisonExpression.java:78)
    at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:48)
    at freemarker.core.Environment.visit(Environment.java:344)
    at freemarker.core.Environment.visit(Environment.java:386)
    at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:886)
    at freemarker.core.Environment.invokeMacro(Environment.java:822)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:83)
    at freemarker.core.Environment.visit(Environment.java:380)
    at freemarker.core.Environment.invokeNestedContent(Environment.java:630)
    at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60)
    at freemarker.core.Environment.visit(Environment.java:380)
    at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:886)
    at freemarker.core.Environment.invokeMacro(Environment.java:822)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:83)
    at freemarker.core.Environment.visit(Environment.java:380)
    at freemarker.core.Environment.invokeNestedContent(Environment.java:630)
    at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60)
    at freemarker.core.Environment.visit(Environment.java:380)
    at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:886)
    at freemarker.core.Environment.invokeMacro(Environment.java:822)
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:83)
    at freemarker.core.Environment.visit(Environment.java:344)
    at freemarker.core.Environmen

Expected behavior

We should not exception on a rate limit in our hosted workflows

Screenshots

If applicable, add screenshots to help explain your problem. Delete this section if it is not applicable.

image

Platform

(Please complete the following information) dev setup

reported context - https://inversoft.slack.com/archives/C053FC35CF9/p1727329585928589

Community guidelines

All issues filed in this repository must abide by the FusionAuth community guidelines.

Additional context

Add any other context about the problem here.