Store Your Password - fetus-hina/stat.ink GitHub Wiki

Store Your Password パスワードの保存

TL;DR

  • Your password will be stored to our DB securely with latest technology.
    パスワードは最新の技術を使用して安全にデータベースに保存されます。

  • Your password will be hashed (simply: encrypted) and won't be decrypted by author or attacker.
    パスワードはハッシュ化(「暗号化」)され、管理者や攻撃者は復元することができません。

  • Nevertheless, create a password that is strong enough.
    それらにかかわらず、強いパスワードを作成して使用してください。

Is my password stores securely? パスワードは安全に保存されますか?

Yes, of course.
はい、もちろん。

Our system "encrypts(*)" your password with a "hash function" based on the latest technology and stores it. Once hashed, no one can access to your raw password (including the author).
stat.inkシステムはパスワードを最新の技術に基づくハッシュ関数で「暗号化(*)」して保存します。
生パスワードは管理者も含めて誰も取得することができません。

At this time, your password will be hashed using the Argon2id algorithm.
And it will be updated accordingly if necessary.
現時点では、パスワードは Argon2id アルゴリズムを使用して「暗号化」されます。
また、必要があれば最新のアルゴリズムに更新し、強度を保ちます。

(*) "encrypt": Technically, the "encrypt" is not the correct term.
(*) 「暗号化」: 技術的には「暗号化」は正しくない用語です。正しくは「ハッシュ化」などと言います。

If our database is leaked due to some kind of accident, the hashed password will be known to the attacker ("cracker", maybe you know as a "hacker").
もし、何らかの事故などによってデータベースの内容が漏れた場合、ハッシュ化されたパスワードが攻撃者に知られることになります。(攻撃者はクラッカー、一般にハッカーとして知られる存在だと考えればよいでしょう)

They'll try to get your password to log in to our website or for another purpose, but it is impossible in the realistic time.
攻撃者はstat.inkにログインするためまたは別の目的のために実際のパスワードを得ようとしますが、現実的な時間ではそれは不可能です。(よって、安全と見なせます)

However, if you use a sufficiently simple password (e.g., "password", "qwerty1234"), the attacker will be able to log in quickly by trying them first.
しかし、もし単純なパスワード(例えば "password" や "qwerty1234")を利用している場合、攻撃者はまずそれらのデータを一通り試してみることで実際のパスワードを素早く知ることができてしまいます。

So, you should use strong password and don't use same the password with another website or application.
ですから、十分な強度を持ったパスワードを作成し、他のサイトやアプリと共用しないようにしてください。

Password requirements パスワードに対する要求

  • All characters can be used. (Even you can use emoji 😀, kanji 漢字, Arabic alphabet العَرَبِيَّة‎ and so on if the browser allows.)
    すべての文字が使用可能です。(ブラウザが許すなら、絵文字、漢字、アラビア文字なども入力できます)

  • 10 characters or more (recommended: 12 characters or more)
    10 文字以上で作成してください(推奨: 12 文字以上)

  • The maximum number of characters is not defined (Accepts up to a few megabytes, but have not tested. I believe no one is using such a password.)
    最大文字数は未定義です。(数メガバイトまで受け入れるはずですが、テストしていません)

How to generate strong password? パスワードの生成方法

  1. Use the password generator that built in to the browser.
    ブラウザに内蔵のパスワードジェネレータを使用します。

  2. Use the password generator that built in the password manager software.
    パスワード管理アプリに付属のパスワードジェネレータを使用します。

  3. Use the password generator that provided on the web like 1Password's.
    ウェブ上の信頼できるパスワードジェネレータを使用します。例えば 1Password

Where can I verify the process? どうやって検証したらいいですか?

When you register to our system, your data is processed by app\models\RegisterForm.
システムにユーザー登録するとき、データはapp\models\RegisterFormによって処理されます。

If the input content is validated, the toUserModel method will be called.
入力が検証されたあと、toUserModel メソッドが呼び出されます。

In the method, Password::hash() is called and your password will be hashed.
そのメソッドで Password::hash() メソッドが呼び出され、パスワードがハッシュ化されます。

Here is the implementation of the Password::hash() function.
Password::hash() メソッドの実装はこれです。

In the current environment, the Argon2id algorithm is selected as described above.
現在の環境では、Argon2id アルゴリズムが選択されます。

In the past, Bcrypt and Argon2i algorithms were selected.
過去には、Brypt や Argon2i アルゴリズムが選択されていました。

The preprocess method does nothing with the Argon algorithms.
preprocess メソッドは、Argon アルゴリズムでは何も行いません。

The Bcrypt algorithm used preprocessing to ease the restrictions(*).
Bcrypt アルゴリズムでは、Bcrypt の制限(*)を緩和するために事前処理が行われます。

(*) Bcrypt restrictions: If simply use the Bcrypt algorithm, the maximum password length is limited to 72 characters.
(*) Bcrypt の制限: Bcrypt アルゴリズムを単純に使用した場合、パスワードの最大長が72文字に制限されます。

Upgrading hash function ハッシュのアップグレード

When a new hash function becomes available in our system, it will be stored to the database using the new hash function at the time of new registration.
新しいアルゴリズムが利用可能になった場合、ユーザー登録時に新しいアルゴリズムでハッシュ化されて保存されるようになります。

For passwords stored in the past, we cannot update "hashed value of your password" because we cannot know the actual password.
Those passwords will be upgraded when you log into our system.
過去に登録されたパスワードについては、パスワードがハッシュ化されており、実際のパスワードがわからないため自動アップグレードすることができません。
それらのパスワードについては、ログイン時に自動的に新しいアルゴリズムを使用するように更新されます。

This is a best practice as far as I know.
これは私の知る最良の方法です。

Examples of passwords that are actually stored to the DB 実際にデータベースに格納されるパスワードの例

  • The password "password" with Argon2id (current algorithm):
    • $argon2id$v=19$m=65536,t=4,p=1$SFlnLi54UGs5eThVcXo0Nw$ThCfkdY4QB6spqRH5MGY4AHVvQJbnk6atfaPaehZmxM
    • $argon2id$v=19$m=65536,t=4,p=1$QUNIS0xnbUxOVzNzTnNDVw$XALZgNidmKTiRpZmtpNB0PXL5hmJ3tOapAvzVMlHu4E
    • $argon2id$v=19$m=65536,t=4,p=1$WVdDbHQveFhGdk55Tm8zTw$gVGmuWqDc5VjxVTPKZeg33GBVQ+I/EIiEbkoEWE1cfU
    • $argon2id$v=19$m=65536,t=4,p=1$ZUVVYmhjMzRwanA3NkpxYQ$JSTG3R/loXa4AiWckIbRJRQIiVJUK6U6Zu/9H6PXuII
    • $argon2id$v=19$m=65536,t=4,p=1$QTQ3ZzI2cmRGejQ2aU42RQ$ETaR9g/TC0s6YMI/OEPaUPaWpfaW1OPXVd1BWfUTHgg
    • $argon2id$v=19$m=65536,t=4,p=1$U1lMcmIzTzg0ZU4zbXhKSQ$E0p7qsjYvUs+qBQVVE0L4w/MN4N7HH3Yl1EhMo5Wa3Q
    • $argon2id$v=19$m=65536,t=4,p=1$TWlCcVlyaUttcFUuVEQzTQ$HzSvaWg4yHFYizvrxzyNcsG9BGkXNuWDxuSi35jOooA
    • $argon2id$v=19$m=65536,t=4,p=1$cUs4ODBvdVpiSVdGaS5yaQ$kL3NFgM/i81YSb5YquU+farXD/zAM4uS/sfsw99muIs
    • $argon2id$v=19$m=65536,t=4,p=1$WDZDbWFOcGlDL2FxVGE5Vg$/2ThniDRp5YFvukqhkRaxX6nJbILQdAue8Zlpek+QWI
    • $argon2id$v=19$m=65536,t=4,p=1$ZVdwbUtmLlB5ekV0OHJsbA$o+cfRsHS/qweJb1XqcsxiteGW0yKptR7cDqfpq8gGtM
  • The password "password" with Argon2i (old):
    • $argon2i$v=19$m=65536,t=4,p=1$SGw2SnFyb2cyUmFJWHY4Qw$sYGZCOcPO85mzPGeknNiORMunjtiIA5jGjNj9FtAydU
    • $argon2i$v=19$m=65536,t=4,p=1$Z0JnalF2MHdQcksxOWFQeg$UxpkZs5DjCGwbkyKnYfKe2v/Nuoo2wds/tKzj0Jg8m8
    • $argon2i$v=19$m=65536,t=4,p=1$RlFTOVBLeERsME15ZFpQYw$HO9lwZfkngIYencPKt6W4Tkp8IVvkknh2HIpeg1ogv8
    • $argon2i$v=19$m=65536,t=4,p=1$RjJEbHNuNmR0cVFJZ2ZrMw$YutIQ2VzP2zp86cZboIo8L2V4mB8za99z47gnfnSVu0
    • $argon2i$v=19$m=65536,t=4,p=1$OTZLSHgyYjR0VW5Zb3g3SQ$sc5Q5gnnEvsQpEuKPjEaqLJnaC1Tz34IQvavm8tVXdc
    • $argon2i$v=19$m=65536,t=4,p=1$dGtSRzh5QVhSZmR3WXBtbw$jaOpsDT44avbJph3qTcKLiMsXOHOxgY+LT4hcqJh0vU
    • $argon2i$v=19$m=65536,t=4,p=1$OS5QS1g3cGRWSEhFdUhGdQ$Bu6MwA+dH1WEeDPmexuiOaofTTS1QdFWMZ4WqCqlQB4
    • $argon2i$v=19$m=65536,t=4,p=1$aG16b1VTZ2FnMGJ4QjNjSw$JGdkoA1xnI5UQdeDIBsHvWwlB6xrPM3dOP1fvtSSbHQ
    • $argon2i$v=19$m=65536,t=4,p=1$MFVhR0Jsc1hHVUJiby5maw$4WOfeS0sJeEgY12kGh2ZsOG9qkKrf1ofP1KXgXtJgMw
    • $argon2i$v=19$m=65536,t=4,p=1$cDBnNk5rdE1ObVR3cndOLg$/KkEJ8PJtooVRf97BnPG6Cxon1/WnOnpX4P8vKGc1II
  • The password "password" with Bcrypt (old):
    • $2y$10$AD6B1IUeaOSDgfNb7WCMreEgAJXMfMC8EEqP6xAcDI8zcPQUzd3dy
    • $2y$10$yIiW9oaxz3XbgS4jnnz8BeQhfVtqqtDPqzKwmgmV/B82NGLoQr/b.
    • $2y$10$0kUDmPjTeHAvk9iyGJu6z.CbGEcRwz1WIPc9/4QAilv/5nyo/0m7K
    • $2y$10$zJlOPgA1KT16H5CNWOTR2.XH.mewz3w9RUwW1jrB/J5Qct/QUKbtq
    • $2y$10$CsnhK2ILWb4EgIFUS/5yAOCQoXjWjbOYNxpZFDXtivnc10m3EyjJ.
    • $2y$10$LTUzO.gIL/VO/Z7UfGKeROnE3CAW2th3Xe4fs3zJfi2y2fA9oeqEe
    • $2y$10$3tDG.f5dVpNhV8n1lP5zieZPs0MdwyqYFPEW2VlJCi/QnDb6F8A4i
    • $2y$10$O/jqMWPiB3PmLRE.dxc0eew4SkU7bPqzbeBYqwxyEkk7pdQ1lL4om
    • $2y$10$8pOdZbxmg/DiiplPcXl9DePqDnrubO185Uc7wMwpAMWHvm4dVfRrW
    • $2y$10$tsE.Gz71hqx76cpb3TJv.uR6c5sw/LEK7xBBttZEtYoFqe.orotMK

Even if you use the same password as someone else, they are stored as different values.
Nevertheless, avoid using simple passwords (e.g., "password", "qwerty").
他の人と同じパスワードを設定したとしても、データベースに保存される値はそれぞれ異なったものになります。(ので、同じパスワードであることすらわかりません)
しかし、シンプルなパスワード(例えば "password" や "qwerty")を設定するのはやめてください。