1
1

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 1 year has passed since last update.

VS CodeのWebアプリ開発で、Snyk拡張機能がリアルタイムに脆弱性チェックしてくれた件

Last updated at Posted at 2022-08-13

はじめに

VS CodeでWebアプリ開発中に、脆弱性チェックを行ってみました。

脆弱性診断ツールは、Snyk(スニーク)を使用

  • 安全で迅速な開発を支援する、デベロッパーファーストのセキュリティプラットフォーム
  • コードの依存OSSやコンテナ/IaCにおける脆弱性を見つけ、優先順位をつけ自動修正
  • Gitや統合開発環境(IDE)、CI/CDパイプラインに直接組み込め、簡単に使用可能

※ 引用元: https://go.snyk.io/jp.html

検証対象のWebアプリに、vulpy を使用

  • 良い/悪いコードを比較するためのWebアプリで、Web Application Security Lab謹製
  • Python/Flask/SQLiteで開発された、2つの側面を持つWebアプリ

検証環境

  • Windows 10
  • VS Code
    • Snyk 拡張機能

検証開始

GitHubからvulpyプロジェクトをclone

> git clone https://github.com/fportantier/vulpy

VS Codeでvulpyを開く

  • VS Codeで、vulpyをクローンしたフォルダを開く

image.png

  • VS Codeターミナルからvulpyをインストール
> pip3 install --user -r requirements.txt

image.png

VS CodeでSnykの拡張機能をインストールし、スキャンを実施

image.png

脆弱性チェックの結果

image.png

セキュリティとクォリティーの二つの側面から診断、レベル分け(H、M)し指摘

  • CODE SECURITY
    • サニタイズ漏れによる、SQL Injection発生リスク
    • サニタイズ漏れによる、Cross-Site Scripting attack (XSS)発生リスク
  • CODE QUALITY
    • クローズ漏れ: Missing close

※ 当該脆弱性を、他のプロジェクトではどのように修正したかまで示してくれる、ありがたい。

サニタイズ漏れの詳細

  • サニタイズ漏れによる、SQL Injection発生リスク
Unsanitized input from a web form [:16]
flows [:16, :16, :20, :5, :5, :12, :12, :12] into execute [:12], 
where it is used in an SQL query. 
This may result in an SQL Injection vulnerability.

注目すべきは、画面右下の脆弱性の修正方法

image.png

  • サニタイズ漏れによる、Cross-Site Scripting attack (XSS)発生リスク
Unsanitized input from a web form [:16]
flows [:16, :16, :20, :20, :20, :22, :26, :32, :32, :32, :33] into the return value of do_login [:33],
where it is used to render an HTML page returned to the user.
This may result in a Cross-Site Scripting attack (XSS).

image.png

クローズ漏れの詳細

ファイルディスクリプタのクローズ漏れなど指摘

image.png

おわりに

VS Codeでコーディング中に、脆弱性チェックをリアルタイムで実施できました。
脆弱性の不安を解消したい方は、Snyk 拡張機能が1つの選択肢かもしれません。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?