Skip to content
This repository has been archived by the owner on Jul 19, 2020. It is now read-only.

暗号化されたCookieに謎の接頭辞「ENC_」が付与されてしまう #131

Closed
SofPyon opened this issue Dec 21, 2019 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@SofPyon
Copy link
Owner

SofPyon commented Dec 21, 2019

再現環境

さくらのレンタルサーバー
(本番環境のみで再現)

不具合の内容

  • 謎の「ENC_」という接頭辞がついた Cookie
  • 「2020_session」という謎の Cookie

image

  • ローカル環境(Docker)では問題ない

image

@SofPyon SofPyon added the bug Something isn't working label Dec 21, 2019
@SofPyon
Copy link
Owner Author

SofPyon commented Dec 21, 2019

おそらくこのバグが原因で #126 が発生したと思われる

Axios の機能として、XSRF-TOKEN という Cookie が存在すれば、それを自動的に X-XSRF-TOKEN という HTTP ヘッダにして送ってくれるという機能があるが、「ENC_」という接頭辞が邪魔してしまい、Axios が XSRF-TOKEN を送ってくれなかった。

結果として Laravel が 419 エラーを返していたと思われる。


追記(2020/01/16): さくらのレンサバの WAF のせいだった。WAF は、接頭辞「ENC_」を付けて Cookie を暗号化するだけでなく、httponly にしてしまうらしい。

Cookie の暗号化自体は Laravel 側でも動作するので、WAF が Cookie を暗号化する処理は冗長と言える。とはいえ、WAF を有効にしたほうが安心感が高いので、とりあえず WAF の利用は継続する。

@SofPyon SofPyon self-assigned this Dec 21, 2019
@hosakou
Copy link
Collaborator

hosakou commented Jan 10, 2020

http://blog.inasoft.org/article/102947798.html
「ENC_」はこのページによると WAF のせいらしいです!

@SofPyon
Copy link
Owner Author

SofPyon commented Jan 10, 2020

@hosakou
そういうことか!ありがとう!!
そういえば何となく WAF オンにしてた…笑

原因が分かったのと、今のところ ENC_ のせいで不都合が生じているわけではなさそうなので、この issue は閉じます!

@SofPyon SofPyon closed this as completed Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants