oliver-zehentleitner / maity
hub: second_factor.state, session_view and view read the factor row once (up to three reads per gate, and the gate runs once per bootstrap part)
tsk-b66k55admewq Open
Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: slow path on a hot route.
What is wrong
deps.py:80runsgateon every authenticated call;gatecallsstate(hub/src/maity_hub/auth/second_factor.py:186-212).- At the second step,
via()runs at:194and again insidestep_life()(:196->:168), each with its ownfactor_ofread. - For an enrolment session,
asks()(:202,factor_ofat:156) andmust_enrol()(:207,factor_ofat:128) both read the row. - For a full session,
must_enrolreadsfactor_of, plusverified_row/ever_had_addressunderemail, oris_instance_admin/owns_a_projectunderrequired_admins. GET /bootstrapcallsgatefor the request (routes/bootstrap.py:168) and again per part (:91, up to 5 parts): up to 6 times per bootstrap.session_view(second_factor.py:254-276) callsstate, thenstep_lifeandviaagain (up to 4factor_ofreads);view()(:955-974) callspolicy()three times andasks/must_enrol, which read the row again.
Proposal
- Read the factor once in
state,session_viewandviewand pass it intovia,asks,must_enrol,step_life(an optionalfactor=argument). - tsk-fr6hmpdabmgr item 1 covers only the
instance_settingread behindpolicy(); this can also serve tsk-nndcfpwxbd3p (bootstrap statements) as a concrete item.
Effort / risk: S. Low; the two-factor and mail-factor tests pin the states.