Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: appプロトコルでfetch可能なディレクトリを制限する #2153

Merged
merged 3 commits into from
Jul 6, 2024

Conversation

sabonerune
Copy link
Contributor

内容

Electronのベストプラクティスに基づきセキュリティを強化します。
18. Avoid usage of the file:// protocol and prefer usage of custom protocols

ref: https://www.electronjs.org/ja/docs/latest/api/protocol#protocolhandlescheme-handler

その他

app://プロトコルのファイルパスを制限して意図しないファイルの読み込みを防ぎます。

@sabonerune sabonerune requested a review from a team as a code owner July 2, 2024 10:16
@sabonerune sabonerune requested review from Hiroshiba and removed request for a team July 2, 2024 10:16
Comment on lines 436 to 440
const isUnsafe =
path.isAbsolute(relativePath) ||
relativePath.startsWith(`..${path.sep}`) ||
relativePath === ".." ||
relativePath === "";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

return !(
path.isAbsolute(relativePath) ||
relativePath.startsWith(`..${path.sep}`) ||
relativePath === ".."
);

ここと共通化できそうな気がしたのですがrelativePath === ""をどうするかという問題と「あるパスがあるパスの親ディレクトリであるか」を判定する関数を作ると考慮漏れやミスが起きそうでとりあえずしていません。

Copy link
Member

Choose a reason for hiding this comment

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

ですね! 役割が違ってくる思うので、共通化は避けるべきだと思います!

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

ほぼLGTMです!!
助かります!!

あ、コメントでコードの参考にしたURL載せても良いかも。

src/backend/electron/main.ts Outdated Show resolved Hide resolved
Co-authored-by: Hiroshiba <hihokaruta@gmail.com>
@sabonerune sabonerune requested a review from Hiroshiba July 4, 2024 09:19
Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

LGTM!!!

@Hiroshiba Hiroshiba merged commit 3ce6c7e into VOICEVOX:main Jul 6, 2024
9 checks passed
@sabonerune sabonerune deleted the feat/validate-befor-app-fetch branch July 6, 2024 15:27
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.

2 participants