0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

nonce覚書

Last updated at Posted at 2021-01-15

きっかけ

  • Bitfinexのnonce smallにハマりまくったので、記録を残す

覚書

  • nonceとは、リプライ攻撃を避けるためのシーケンシャルな番号
  • 通常はepoch時間等を使うが、前回+1とかでも一応OK
  • 短い時間に連続で送ると、クライアント側は順番でも、サーバへの到着が逆になってNGになる
  • 間違って大きい値を送りOKになると、その後小さい値に戻してもサーバ側で記憶しているとNGになる
  • 双方の実装によるが、指数表記でもいける

気をつけないといけないこと

  • nonce smallが出るたびに*10とかしていった結果、実質APIが使えなくなる。。。

気をつけないといけないこと2(2021/01/27追記)

  • https通信は基本的に非同期なので、先のリクエスト(nonceが小さい)が相手のサーバに後から到着することもありえる。
  • すると、後のリクエスト(nonceが大きい)が先に来た後に処理され、不正なリクエストとなるので、到着までしっかり待たないと、短い時間に連続で処理を出す場合はNGがちらほらでる
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?