moov-io / achgateway

Payment gateway enabling automated ACH operations in a distributed and fault tolerant way.
https://moov-io.github.io/achgateway/
Apache License 2.0
54 stars 19 forks source link

Incorrect behavior when pinned SFTP key changes on running instance #199

Open jrnt30 opened 1 year ago

jrnt30 commented 1 year ago

Had a bit of a weird one recently with v0.23.4. We have explicitly pinned our valid SSH key for an SFTP host in our configuration. During the course of the application being up, our banking partner adjusted their public key that we had previously pinned to a different value and the application continued to operate as if things were OK.

Observed Behavior

Expected Behavior

adamdecaf commented 1 year ago

That's quite odd. I'm assuming the connection was left open between the key rotation? I don't understand why the SFTP server would not save files, but also wouldn't tell you of such errors. I'm not sure how the SFTP library could detect a changed key or that files weren't actually written (without trying to open each file after write).

adamdecaf commented 1 year ago

HostKeyCallback is only called by the ssh client during the handshake, so if there's no further handshakes the client wouldn't notice that the key changed.

We could be more aggressive about closing upload.Agent's but that comes at a performance cost. I've looked at closing upload.Agent's and removing the cache which would help detect this sooner.