Skip to content

Commit eb9d583

Browse files
Merge pull request #39 from snyk/feat/json-vuln-per-evidence
feat: translate each Evidence Path on a finding into a separate legacy JSON finding
2 parents 96785a1 + b64023d commit eb9d583

File tree

6 files changed

+459
-27
lines changed

6 files changed

+459
-27
lines changed

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.24.1
66

77
require (
88
github.com/charmbracelet/lipgloss v0.10.0
9-
github.com/gkampitakis/go-snaps v0.5.3
9+
github.com/gkampitakis/go-snaps v0.5.14
1010
github.com/golang/mock v1.6.0
1111
github.com/google/uuid v1.6.0
1212
github.com/muesli/termenv v0.15.2
@@ -36,13 +36,14 @@ require (
3636
github.com/emirpasic/gods v1.18.1 // indirect
3737
github.com/fsnotify/fsnotify v1.5.4 // indirect
3838
github.com/getkin/kin-openapi v0.131.0 // indirect
39-
github.com/gkampitakis/ciinfo v0.3.0 // indirect
39+
github.com/gkampitakis/ciinfo v0.3.2 // indirect
4040
github.com/gkampitakis/go-diff v1.3.2 // indirect
4141
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
4242
github.com/go-git/go-billy/v5 v5.6.2 // indirect
4343
github.com/go-git/go-git/v5 v5.14.0 // indirect
4444
github.com/go-openapi/jsonpointer v0.21.1 // indirect
4545
github.com/go-openapi/swag v0.23.1 // indirect
46+
github.com/goccy/go-yaml v1.18.0 // indirect
4647
github.com/gofrs/flock v0.12.1 // indirect
4748
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
4849
github.com/hashicorp/go-uuid v1.0.3 // indirect
@@ -98,7 +99,7 @@ require (
9899
github.com/spf13/jwalterweatherman v1.1.0 // indirect
99100
github.com/spf13/viper v1.13.0 // indirect
100101
github.com/subosito/gotenv v1.4.1 // indirect
101-
github.com/tidwall/gjson v1.17.0 // indirect
102+
github.com/tidwall/gjson v1.18.0 // indirect
102103
github.com/tidwall/match v1.1.1 // indirect
103104
github.com/tidwall/pretty v1.2.1 // indirect
104105
github.com/tidwall/sjson v1.2.5 // indirect

go.sum

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
[]definitions.Vulnerability{
2+
{
3+
CVSSv3: &"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N",
4+
AlternativeIds: (*[]string)(nil),
5+
CreationTime: "2025-06-03T07:41:24.000000Z",
6+
Credit: &[]string{"Caleb Brown"},
7+
CvssDetails: &[]definitions.CVSSDetail{
8+
},
9+
CvssScore: &float32(8.699999809265137),
10+
CvssSources: &[]definitions.CVSSSource{
11+
{
12+
Assigner: &"Snyk",
13+
BaseScore: &float32(8.699999809265137),
14+
CvssVersion: &"4.0",
15+
ModificationTime: &"2025-06-03T10:14:39.305713Z",
16+
Severity: &"high",
17+
Type: &"primary",
18+
Vector: &"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N",
19+
},
20+
{
21+
Assigner: &"Snyk",
22+
BaseScore: &float32(7.5),
23+
CvssVersion: &"3.1",
24+
ModificationTime: &"2025-06-03T10:14:39.305713Z",
25+
Severity: &"high",
26+
Type: &"secondary",
27+
Vector: &"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N",
28+
},
29+
},
30+
Description: "## Overview\n[tar-fs](https://www.npmjs.com/package/tar-fs) is a filesystem bindings for tar-stream.\n\nAffected versions of this package are vulnerable to Improper Link Resolution Before File Access ('Link Following') through the `exports.extract` function. An attacker can manipulate the path of extracted files to write outside the intended directory by crafting a malicious tarball.\r\n\r\n## Workaround \r\nThis vulnerability can be mitigated by using the ignore option to ignore paths like symlinks that are not files/directories.\r\n```js\r\n ignore (_, header) {\r\n // pass files & directories, ignore e.g. symlinks\r\n return header.type !== 'file' && header.type !== 'directory'\r\n }\r\n```\n\n## Details\n\nA Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with \"dot-dot-slash (../)\" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.\n\nDirectory Traversal vulnerabilities can be generally divided into two types:\n\n- **Information Disclosure**: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.\n\n`st` is a module for serving static files on web pages, and contains a [vulnerability of this type](https://snyk.io/vuln/npm:st:20140206). In our example, we will serve files from the `public` route.\n\nIf an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.\n\n```\ncurl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa\n```\n**Note** `%2e` is the URL encoded version of `.` (dot).\n\n- **Writing arbitrary files**: Allows the attacker to create or replace existing files. This type of vulnerability is also known as `Zip-Slip`. \n\nOne way to achieve this is by using a malicious `zip` archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.\n\nThe following is an example of a `zip` archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in `/root/.ssh/` overwriting the `authorized_keys` file:\n\n```\n2018-04-15 22:04:29 ..... 19 19 good.txt\n2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys\n```\n\n## Remediation\nUpgrade `tar-fs` to version 1.16.5, 2.1.3, 3.0.9 or higher.\n## References\n- [GitHub Commit](https://github.com/mafintosh/tar-fs/commit/647447b572bc135c41035e82ca7b894f02b17f0f)\n- [Red Hat Bugzilla Bug](https://bugzilla.redhat.com/show_bug.cgi?id=2369875)\n",
31+
DisclosureTime: &"2025-06-02T19:43:25.000000Z",
32+
EpssDetails: (*definitions.EPSDetails)(nil),
33+
Exploit: (*string)(nil),
34+
ExploitDetails: &definitions.ExploitDetails{
35+
MaturityLevels: {
36+
{Format:"", Level:"", Type:"secondary"},
37+
{Format:"CVSSv4", Level:"not defined", Type:"primary"},
38+
},
39+
Sources: {},
40+
},
41+
Filtered: (*definitions.VulnFiltered)(nil),
42+
FixedIn: &[]string{"1.16.5", "2.1.3", "3.0.9"},
43+
From: {"v2@*", "@yao-pkg/[email protected]", "[email protected]", "[email protected]"},
44+
Functions: (*[]definitions.FunctionInfo)(nil),
45+
FunctionsNew: (*[]definitions.NewFunctionInfo)(nil),
46+
Id: "SNYK-JS-TARFS-10293725",
47+
Identifiers: &definitions.Identifiers{
48+
ALTERNATIVE: (*[]string)(nil),
49+
CVE: {"CVE-2025-48387"},
50+
CWE: {"CWE-59", "CWE-22"},
51+
GHSA: (*[]string)(nil),
52+
NSP: (*[]string)(nil),
53+
SNYK: (*[]string)(nil),
54+
},
55+
Insights: (*definitions.Insights)(nil),
56+
IsDisputed: (*bool)(nil),
57+
IsPatchable: false,
58+
IsPinnable: (*bool)(nil),
59+
IsRuntime: (*bool)(nil),
60+
IsUpgradable: false,
61+
Language: &"js",
62+
License: (*string)(nil),
63+
Malicious: &bool(false),
64+
ModificationTime: &"2025-06-03T10:14:39.000000Z",
65+
ModuleName: (*string)(nil),
66+
Name: "tar-fs",
67+
PackageManager: &"npm",
68+
PackageName: &"tar-fs",
69+
PackagePopularityRank: (*int32)(nil),
70+
Patch: (*[]string)(nil),
71+
Patches: (*[]definitions.PatchInfo)(nil),
72+
Proprietary: (*bool)(nil),
73+
PublicationTime: &"2025-06-03T10:14:39.000000Z",
74+
Reachability: (*definitions.Reachability)(nil),
75+
References: &[]definitions.Reference{
76+
{Title:"GitHub Commit", Url:"https://github.com/mafintosh/tar-fs/commit/647447b572bc135c41035e82ca7b894f02b17f0f"},
77+
{Title:"Red Hat Bugzilla Bug", Url:"https://bugzilla.redhat.com/show_bug.cgi?id=2369875"},
78+
},
79+
RiskScore: &uint16(0x7c),
80+
Semver: &definitions.SemVerInfo{
81+
Vulnerable: {"<1.16.5", ">=2.0.0 <2.1.3", ">=3.0.0 <3.0.9"},
82+
VulnerableHashes: (*[]string)(nil),
83+
},
84+
Severity: "high",
85+
SeverityBasedOn: (*string)(nil),
86+
SeverityWithCritical: (*definitions.VulnerabilitySeverity)(nil),
87+
SocialTrendAlert: &bool(false),
88+
Title: "Improper Link Resolution Before File Access ('Link Following')",
89+
Type: (*definitions.VulnerabilityType)(nil),
90+
UpgradePath: nil,
91+
Version: "2.1.2",
92+
},
93+
{
94+
CVSSv3: &"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N",
95+
AlternativeIds: (*[]string)(nil),
96+
CreationTime: "2025-06-03T07:41:24.000000Z",
97+
Credit: &[]string{"Caleb Brown"},
98+
CvssDetails: &[]definitions.CVSSDetail{
99+
},
100+
CvssScore: &float32(8.699999809265137),
101+
CvssSources: &[]definitions.CVSSSource{
102+
{
103+
Assigner: &"Snyk",
104+
BaseScore: &float32(8.699999809265137),
105+
CvssVersion: &"4.0",
106+
ModificationTime: &"2025-06-03T10:14:39.305713Z",
107+
Severity: &"high",
108+
Type: &"primary",
109+
Vector: &"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N",
110+
},
111+
{
112+
Assigner: &"Snyk",
113+
BaseScore: &float32(7.5),
114+
CvssVersion: &"3.1",
115+
ModificationTime: &"2025-06-03T10:14:39.305713Z",
116+
Severity: &"high",
117+
Type: &"secondary",
118+
Vector: &"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N",
119+
},
120+
},
121+
Description: "## Overview\n[tar-fs](https://www.npmjs.com/package/tar-fs) is a filesystem bindings for tar-stream.\n\nAffected versions of this package are vulnerable to Improper Link Resolution Before File Access ('Link Following') through the `exports.extract` function. An attacker can manipulate the path of extracted files to write outside the intended directory by crafting a malicious tarball.\r\n\r\n## Workaround \r\nThis vulnerability can be mitigated by using the ignore option to ignore paths like symlinks that are not files/directories.\r\n```js\r\n ignore (_, header) {\r\n // pass files & directories, ignore e.g. symlinks\r\n return header.type !== 'file' && header.type !== 'directory'\r\n }\r\n```\n\n## Details\n\nA Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with \"dot-dot-slash (../)\" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.\n\nDirectory Traversal vulnerabilities can be generally divided into two types:\n\n- **Information Disclosure**: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.\n\n`st` is a module for serving static files on web pages, and contains a [vulnerability of this type](https://snyk.io/vuln/npm:st:20140206). In our example, we will serve files from the `public` route.\n\nIf an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.\n\n```\ncurl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa\n```\n**Note** `%2e` is the URL encoded version of `.` (dot).\n\n- **Writing arbitrary files**: Allows the attacker to create or replace existing files. This type of vulnerability is also known as `Zip-Slip`. \n\nOne way to achieve this is by using a malicious `zip` archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.\n\nThe following is an example of a `zip` archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in `/root/.ssh/` overwriting the `authorized_keys` file:\n\n```\n2018-04-15 22:04:29 ..... 19 19 good.txt\n2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys\n```\n\n## Remediation\nUpgrade `tar-fs` to version 1.16.5, 2.1.3, 3.0.9 or higher.\n## References\n- [GitHub Commit](https://github.com/mafintosh/tar-fs/commit/647447b572bc135c41035e82ca7b894f02b17f0f)\n- [Red Hat Bugzilla Bug](https://bugzilla.redhat.com/show_bug.cgi?id=2369875)\n",
122+
DisclosureTime: &"2025-06-02T19:43:25.000000Z",
123+
EpssDetails: (*definitions.EPSDetails)(nil),
124+
Exploit: (*string)(nil),
125+
ExploitDetails: &definitions.ExploitDetails{
126+
MaturityLevels: {
127+
{Format:"", Level:"", Type:"secondary"},
128+
{Format:"CVSSv4", Level:"not defined", Type:"primary"},
129+
},
130+
Sources: {},
131+
},
132+
Filtered: (*definitions.VulnFiltered)(nil),
133+
FixedIn: &[]string{"1.16.5", "2.1.3", "3.0.9"},
134+
From: {"v2@", "@yao-pkg/[email protected]", "@yao-pkg/[email protected]", "[email protected]"},
135+
Functions: (*[]definitions.FunctionInfo)(nil),
136+
FunctionsNew: (*[]definitions.NewFunctionInfo)(nil),
137+
Id: "SNYK-JS-TARFS-10293725",
138+
Identifiers: &definitions.Identifiers{
139+
ALTERNATIVE: (*[]string)(nil),
140+
CVE: {"CVE-2025-48387"},
141+
CWE: {"CWE-59", "CWE-22"},
142+
GHSA: (*[]string)(nil),
143+
NSP: (*[]string)(nil),
144+
SNYK: (*[]string)(nil),
145+
},
146+
Insights: (*definitions.Insights)(nil),
147+
IsDisputed: (*bool)(nil),
148+
IsPatchable: false,
149+
IsPinnable: (*bool)(nil),
150+
IsRuntime: (*bool)(nil),
151+
IsUpgradable: false,
152+
Language: &"js",
153+
License: (*string)(nil),
154+
Malicious: &bool(false),
155+
ModificationTime: &"2025-06-03T10:14:39.000000Z",
156+
ModuleName: (*string)(nil),
157+
Name: "tar-fs",
158+
PackageManager: &"npm",
159+
PackageName: &"tar-fs",
160+
PackagePopularityRank: (*int32)(nil),
161+
Patch: (*[]string)(nil),
162+
Patches: (*[]definitions.PatchInfo)(nil),
163+
Proprietary: (*bool)(nil),
164+
PublicationTime: &"2025-06-03T10:14:39.000000Z",
165+
Reachability: (*definitions.Reachability)(nil),
166+
References: &[]definitions.Reference{
167+
{Title:"GitHub Commit", Url:"https://github.com/mafintosh/tar-fs/commit/647447b572bc135c41035e82ca7b894f02b17f0f"},
168+
{Title:"Red Hat Bugzilla Bug", Url:"https://bugzilla.redhat.com/show_bug.cgi?id=2369875"},
169+
},
170+
RiskScore: &uint16(0x7c),
171+
Semver: &definitions.SemVerInfo{
172+
Vulnerable: {"<1.16.5", ">=2.0.0 <2.1.3", ">=3.0.0 <3.0.9"},
173+
VulnerableHashes: (*[]string)(nil),
174+
},
175+
Severity: "high",
176+
SeverityBasedOn: (*string)(nil),
177+
SeverityWithCritical: (*definitions.VulnerabilitySeverity)(nil),
178+
SocialTrendAlert: &bool(false),
179+
Title: "Improper Link Resolution Before File Access ('Link Following')",
180+
Type: (*definitions.VulnerabilityType)(nil),
181+
UpgradePath: nil,
182+
Version: "2.1.2",
183+
},
184+
}

0 commit comments

Comments
 (0)