前回の記事では、Golang プログラムの脆弱性スキャン ツール govulncheck の使い方を詳しく紹介しましたが、govulncheck の強力な機能の背後には、Go 脆弱性データベースのサポートが切っても切れない関係にあります。次に、Go 脆弱性に関する知見について詳しく説明します。データベース。
Go 脆弱性データベースとは何ですか?
今日のデジタル世界では、ソフトウェアのセキュリティが非常に重要です。開発分野で Golang の人気が高まるにつれて、Go プロジェクトのセキュリティがますます重要になってきます。開発者が Golang に関連するセキュリティ脆弱性を迅速に発見して解決できるようにするために、Go 脆弱性データベースが作成されました。
https://vuln.go.dev または https://pkg.go.dev/vuln でアクセスできる Go 脆弱性データベース (Go 脆弱性データベース) は、Golang のセキュリティ脆弱性情報を保存するデータベースであり、Golang によって公式に維持されています。脆弱性情報データは、cve、ghsa、Go パッケージ管理者によって直接送信された脆弱性レポートなどの既存のソースから取得され、その後、この情報は Go セキュリティ チームによってレビューされ、データベースに追加されます。
データベースは複数のデータ ソースへのアクセスをサポートし、脆弱性データ ソースにアクセスするためのインターフェイスとデフォルトの実装を提供します。脆弱性項目は、OSV (Open Source Vulnerability format) 形式を使用して保存および送信されます。開発者は、モジュールのパスまたは ID に基づいて、脆弱性データベースから既知の脆弱性を検索できます。
Go 脆弱性データベース API
Go 脆弱性データベースは、HTTP プロトコルに基づいた一連のインターフェイスを提供しており、リクエスト メソッドは GET であり、各インターフェイスは JSON 型のデータを返します。
- データベースのメタデータを取得するインターフェース/index/db.json[.gz]
例は次のとおりです。
$ curl https://vuln.go.dev/index/db.json
{"modified":"2023-08-23T14:38:50Z"}
- 各モジュールのメタデータを取得するinterface/index/modules.json[.gz]
例は次のとおりです。
$ curl https://vuln.go.dev/index/modules.json
[ {
// The module path.
"path": string,
// The vulnerabilities that affect this module.
"vulns":
[ {
// The vulnerability ID.
"id": string,
// The latest time the vulnerability should be considered
// to have been modified, as an RFC3339-formatted UTC
// timestamp ending in "Z".
"modified": string,
// (Optional) The module version (in SemVer 2.0.0 format)
// that contains the latest fix for the vulnerability.
// If unknown or unavailable, this should be omitted.
"fixed": string,
} ]
} ]
- 各脆弱性メタデータの取得interface/index/vulns.json[.gz]
例は次のとおりです。
$ curl https://vuln.go.dev/index/vulns.json
[ {
// The vulnerability ID.
"id": string,
// The latest time the vulnerability should be considered
// to have been modified, as an RFC3339-formatted UTC
// timestamp ending in "Z".
"modified": string,
// A list of IDs of the same vulnerability in other databases.
"aliases": [ string ]
} ]
- 特定の脆弱性情報の取得interface/ID/$id.json[.gz]
例は次のとおりです。
$ curl https://vuln.go.dev/ID/GO-2023-2003.json
{
"schema_version": "1.3.1",
"id": "GO-2023-2003",
"modified": "2023-08-10T22:06:06Z",
"published": "2023-08-10T22:06:06Z",
"aliases": [
"GHSA-8c37-7qx3-4c4p"
],
"summary": "Blst fails to perform group signature validation",
"details": "When complemented with a check for infinity, blst skips performing a signature group-check. Formally speaking, infinity is the identity element of the elliptic curve group and as such it is a member of the group, so the group-check should be performed. The fix performs the check even in the presence of infinity.",
"affected": [
{
"package": {
"name": "github.com/supranational/blst",
"ecosystem": "Go"
},
"ranges": [
{
"type": "SEMVER",
"events": [
{
"introduced": "0.3.0"
},
{
"fixed": "0.3.11"
}
]
}
],
"ecosystem_specific": {
"imports": [
{
"path": "github.com/supranational/blst/bindings/go",
"symbols": [
"P1Affine.SigValidate",
"P2Affine.SigValidate"
]
}
]
}
}
],
"references": [
{
"type": "FIX",
"url": "https://github.com/supranational/blst/commit/fb91221c91c82f65bfc7f243256308977a06d48b"
},
{
"type": "WEB",
"url": "https://github.com/supranational/blst/releases/tag/v0.3.11"
}
],
"credits": [
{
"name": "Yunjong Jeong (@blukat29)"
}
],
"database_specific": {
"url": "https://pkg.go.dev/vuln/GO-2023-2003"
}
}
govulncheck は脆弱性データベース方式を使用します
govulncheck で使用される脆弱性データ アドレスは https://vuln.go.dev です。-db パラメータを使用して脆弱性データベースを指定できます。http://、https://、および file:// プロトコルをサポートします。指定された脆弱性データベースは、上で説明したいくつかの API を実装する必要があります。govulncheck コマンドは、http ソースから読み取る場合は「.json.gz」エンドポイントを使用し、ファイル ソースから読み取る場合は「json」エンドポイントを使用します。