Skip to content

Fix HNSHK security profile version for two-step PIN/TAN - #214

Open
markusrauschergmxnet wants to merge 1 commit into
raphaelm:masterfrom
markusrauschergmxnet:fix/hnshk-pin2-twostep-auth
Open

markusrauschergmxnet wants to merge 1 commit into
raphaelm:masterfrom
markusrauschergmxnet:fix/hnshk-pin2-twostep-auth

Conversation

@markusrauschergmxnet

Copy link
Copy Markdown

Summary

  • HNSHK signature header always used SecurityProfile(PIN, 1) (one-step) even when two-step TAN authentication (e.g. sf=904) was active. The HNVSK encryption header correctly used PIN:2, but HNSHK still said PIN:1.
  • Banks that strictly validate the security profile version — notably HypoVereinsbank (UniCredit) — rejected the HKTAN segment with error 9210 ("Auftrag abgelehnt. Kein eingereichter Auftrag gefunden") because the signature claimed one-step while a two-step HKTAN segment was present.
  • Additionally, _bootstrap_mode was never reset after fetch_tan_mechanisms(), causing 9075 SCA errors to be silently swallowed instead of properly raised.

Changes

  1. fints/security.py: PinTanAuthenticationMechanism now uses a security_method_version attribute (default 1) for the HNSHK security profile. PinTanTwoStepAuthenticationMechanism overrides it to 2, matching the HNVSK behavior.
  2. fints/client.py: _bootstrap_mode is reset to False after fetch_tan_mechanisms() completes, so that subsequent dialog errors (especially 9075) are properly raised.

Test plan

  • Tested with HypoVereinsbank (BLZ 70020270, appTAN sf=904): Dialog init now receives HITAN with challenge instead of 9210
  • Verified DKB, VR Bank, and Sparkasse still work (these banks don't strictly check the profile version)
  • Successfully retrieved 124 transactions + 3 SEPA accounts from HVB after fix

Fixes #213

The HNSHK signature header always used SecurityProfile(PIN, 1) (one-step)
even when two-step TAN authentication was active. This caused an
inconsistency: HNVSK (encryption) correctly used PIN:2 for two-step,
but HNSHK (signature) still said PIN:1.

Banks that strictly validate the security profile version (notably
HypoVereinsbank/UniCredit) rejected the HKTAN segment with error 9210
("Auftrag abgelehnt") because the signature header claimed one-step
authentication while a two-step TAN segment was present in the message.

This also fixes _bootstrap_mode never being reset after
fetch_tan_mechanisms(), which caused 9075 SCA errors to be silently
swallowed instead of properly raised.

Fixes raphaelm#213
@raphaelm

raphaelm commented Jun 2, 2026

Copy link
Copy Markdown
Owner

I'll try to find time to test this against my HVB account soonish

Comment thread fints/client.py
Comment on lines +1308 to +1310
# Bootstrap phase (anonymous dialog with sf=999) is complete.
# Reset so that errors in subsequent authenticated dialogs are properly raised.
self._bootstrap_mode = False

@mt-software-de mt-software-de Oct 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, the bootstrap part solves a problem we ran into as well. It doesn't cover clients restored with from_data, which usually don't call fetch_tan_mechanisms() again and so stay in bootstrap mode, swallowing a 9075. I opened #228, which ends the bootstrap mode in __enter__ instead and covers both cases.

For what it's worth, we can also confirm the security profile change with Consorsbank: PIN:1 in HNSHK is rejected with 9010 Ungültiger Signaturaufbau, PIN:2 works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HVB / UniCredit with appTAN: four bugs + structural SCA gap (picks up from #135)

3 participants