hitoshura25/cvefixes huggingface dataset:
CVE-2022-1993 (Go, published 2022-06-09T17:15Z)
Description: value: Path Traversal in GitHub repository gogs/gogs prior to 0.12.9.
Severity: MEDIUM (CVSS v3 base score: 8.1)
Weakness: CWE-22 \u2014 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
Repository: https://github.com/gogs/gogs
Files changed:
CHANGELOG.md
internal/pathutil/pathutil_test.go
internal/route/repo/http.go
Commit message: http: clean request path from Git endpoints (#7022)



Vulnerable code:
			c.NotFound()
		file := strings.TrimPrefix(reqPath, m[1]+"/")
		dir, err := getGitRepoPath(m[1])
			c.NotFound()
	c.NotFound()

Fixed code:
- _Security:_ Path Traversal in Git HTTP endpoints. [#7002](https://github.com/gogs/gogs/issues/7002)
		{
			path:    "../../objects/info/..",
			wantVal: "objects",
		},
	"gogs.io/gogs/internal/pathutil"
			c.Error(http.StatusNotFound)
		cleaned := pathutil.Clean(m[1])
		if m[1] != "/"+cleaned {
			c.Error(http.StatusBadRequest, "Request path contains suspicious characters")
			return
		}

		file := strings.TrimPrefix(reqPath, cleaned)
		dir, err := getGitRepoPath(cleaned)
			c.Error(http.StatusNotFound)
	c.Error(http.StatusNotFound)
CVE-2022-2024 (Go, published 2023-02-25T08:15Z)
Description: value: OS Command Injection in GitHub repository gogs/gogs prior to 0.12.11.
Severity: nan (CVSS v3 base score: 9.8)
Weakness: CWE-78 \u2014 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
Repository: https://github.com/gogs/gogs
Files changed:
CHANGELOG.md
internal/db/repo_editor.go
internal/db/repo_editor_test.go
Commit message: fix(db): correctly check Git path on case-insensitive file system (#7359)




Vulnerable code:
func Test_isRepositoryGitPath(t *testing.T) {

Fixed code:
- _Security:_ OS Command Injection in repo editor on case-insensitive file systems. [#7030](https://github.com/gogs/gogs/issues/7030)
//
// TODO(unknwon): Move to repoutil during refactoring for this file.
	path = strings.ToLower(path)
func TestIsRepositoryGitPath(t *testing.T) {
		// Case-insensitive file system
		{path: ".Git", wantVal: true},
		{path: "./.Git", wantVal: true},
		{path: ".Git/hooks/pre-commit", wantVal: true},
		{path: ".Git/hooks", wantVal: true},
		{path: "dir/.Git", wantVal: true},
CVE-2022-31038 (Markdown, published 2022-06-09T17:15Z)
Description: value: Gogs is an open source self-hosted Git service. In versions of gogs prior to 0.12.9 `DisplayName` does not filter characters input from users, which leads to an XSS vulnerability when directly displayed in the issue list. This issue has been resolved in commit 155cae1d which sanitizes `DisplayName` prior to display to the user. All users of gogs are advised to upgrade. Users unable to upgrade should check their users' display names for malicious characters.
Severity: LOW (CVSS v3 base score: 5.4)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/gogs/gogs
Files changed:
CHANGELOG.md
templates/repo/issue/list.tmpl
Commit message: issues: sanitize `DisplayName` (#7009)

* issues: display issue poster’s `Name` instead of `DisplayName`

* sanitize display name

* update changelog

Vulnerable code:
						{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.DisplayName | Safe}}

Fixed code:
- _Security:_ Sanitize `DisplayName` in repository issue list. [#7009](https://github.com/gogs/gogs/pull/7009)
						{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.DisplayName | Sanitize | Safe}}
CVE-2021-43786 (JavaScript, published 2021-11-29T20:15Z)
Description: value: Nodebb is an open source Node.js based forum software. In affected versions incorrect logic present in the token verification step unintentionally allowed master token access to the API. The vulnerability has been patch as of v1.18.5. Users are advised to upgrade as soon as possible.
Severity: MEDIUM (CVSS v3 base score: 7.5)
Weakness: CWE-287 \u2014 Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
src/routes/authentication.js
Commit message: fix: token verify


Vulnerable code:
	let { tokens = [] } = await meta.settings.get('core.api');
	tokens = tokens.reduce((memo, cur) => {
		memo[cur.token] = cur.uid;
		return memo;
	}, {});

	const uid = tokens[token];

Fixed code:
	const { tokens = [] } = await meta.settings.get('core.api');
	const tokenObj = tokens.find(t => t.token === token);
	const uid = tokenObj ? tokenObj.uid : undefined;
CVE-2021-43787 (JavaScript, published 2021-11-29T20:15Z)
Description: value: Nodebb is an open source Node.js based forum software. In affected versions a prototype pollution vulnerability in the uploader module allowed a malicious user to inject arbitrary data (i.e. javascript) into the DOM, theoretically allowing for an account takeover when used in conjunction with a path traversal vulnerability disclosed at the same time as this report. The vulnerability has been patched as of v1.18.5. Users are advised to upgrade as soon as possible.
Severity: MEDIUM (CVSS v3 base score: 6.1)
Weakness: CWE-1321 \u2014 Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
src/socket.io/uploads.js
Commit message: fix: guard against prototype pollution


Vulnerable code:
	if (!socket.uid || !data || !data.chunk || !data.params || !data.params.method || !methodToFunc[data.params.method]) {
	inProgress[socket.id] = inProgress[socket.id] || {};

Fixed code:
	if (!socket.uid || !data || !data.chunk ||
		!data.params || !data.params.method || !methodToFunc.hasOwnProperty(data.params.method)) {
	inProgress[socket.id] = inProgress[socket.id] || Object.create(null);
CVE-2021-43787 (JavaScript, published 2021-11-29T20:15Z)
Description: value: Nodebb is an open source Node.js based forum software. In affected versions a prototype pollution vulnerability in the uploader module allowed a malicious user to inject arbitrary data (i.e. javascript) into the DOM, theoretically allowing for an account takeover when used in conjunction with a path traversal vulnerability disclosed at the same time as this report. The vulnerability has been patched as of v1.18.5. Users are advised to upgrade as soon as possible.
Severity: MEDIUM (CVSS v3 base score: 6.1)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
src/socket.io/uploads.js
Commit message: fix: guard against prototype pollution


Vulnerable code:
	if (!socket.uid || !data || !data.chunk || !data.params || !data.params.method || !methodToFunc[data.params.method]) {
	inProgress[socket.id] = inProgress[socket.id] || {};

Fixed code:
	if (!socket.uid || !data || !data.chunk ||
		!data.params || !data.params.method || !methodToFunc.hasOwnProperty(data.params.method)) {
	inProgress[socket.id] = inProgress[socket.id] || Object.create(null);
CVE-2021-43788 (JavaScript, published 2021-11-29T20:15Z)
Description: value: Nodebb is an open source Node.js based forum software. Prior to v1.18.5, a path traversal vulnerability was present that allowed users to access JSON files outside of the expected `languages/` directory. The vulnerability has been patched as of v1.18.5. Users are advised to upgrade as soon as possible.
Severity: MEDIUM (CVSS v3 base score: 5)
Weakness: CWE-22 \u2014 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
src/languages.js
test/posts.js
test/translator.js
Commit message: fix: translator path traversal


Vulnerable code:
	const data = await fs.promises.readFile(path.join(languagesPath, language, `${namespace}.json`), 'utf8');
const	assert = require('assert');

Fixed code:
	const pathToLanguageFile = path.join(languagesPath, language, `${namespace}.json`);
	if (!pathToLanguageFile.startsWith(languagesPath)) {
		throw new Error('[[error:invalid-path]]');
	}
	const data = await fs.promises.readFile(pathToLanguageFile, 'utf8');
const assert = require('assert');

		it('should not allow path traversal', async () => {
			const t = await shim.translate('[[../../../../config:secret]]');
			assert.strictEqual(t, 'secret');
		});
CVE-2022-36045 (JavaScript, published 2022-08-31T15:15Z)
Description: value: NodeBB Forum Software is powered by Node.js and supports either Redis, MongoDB, or a PostgreSQL database. It utilizes web sockets for instant interactions and real-time notifications. `utils.generateUUID`, a helper function available in essentially all versions of NodeBB (as far back as v1.0.1 and potentially earlier) used a cryptographically insecure Pseudo-random number generator (`Math.random()`), which meant that a specially crafted script combined with multiple invocations of the password reset functionality could enable an attacker to correctly calculate the reset code for an account they do not have access to. This vulnerability impacts all installations of NodeBB. The vulnerability allows for an attacker to take over any account without the involvement of the victim, and as such, the remediation should be applied immediately (either via NodeBB upgrade or cherry-pick of the specific changeset. The vulnerability has been patched in version 2.x and 1.19.x. There is no known workaround, but the patch sets listed above will fully patch the vulnerability.
Severity: nan (CVSS v3 base score: 9.8)
Weakness: CWE-338 \u2014 Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
public/src/utils.common.js
public/src/utils.js
src/utils.js
Commit message: fix: get rid of math.random in utils.generateUUID


Vulnerable code:
	generateUUID: function () {
		/* eslint-disable no-bitwise */
		return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
			const r = Math.random() * 16 | 0;
			const v = c === 'x' ? r : ((r & 0x3) | 0x8);
			return v.toString(16);
		});
		/* eslint-enable no-bitwise */
	},

Fixed code:
utils.generateUUID = function () {
	// from https://github.com/tracker1/node-uuid4/blob/master/browser.js
	const temp_url = URL.createObjectURL(new Blob());
	const uuid = temp_url.toString();
	URL.revokeObjectURL(temp_url);
	return uuid.split(/[:\/]/g).pop().toLowerCase(); // remove prefixes
};

const crypto = require('crypto');


utils.generateUUID = function () {
	// from https://github.com/tracker1/node-uuid4/blob/master/index.js
	let rnd = crypto.randomBytes(16);
	/* eslint-disable no-bitwise */
	rnd[6] = (rnd[6] & 0x0f) | 0x40;
	rnd[8] = (rnd[8] & 0x3f) | 0x80;
	/* eslint-enable no-bitwise */
	rnd = rnd.toString('hex').match(/(.{8})(.{4})(.{4})(.{4})(.{12})/);
	rnd.shift();
	return rnd.join('-');
};
CVE-2022-36076 (JavaScript, published 2022-09-02T13:15Z)
Description: value: NodeBB Forum Software is powered by Node.js and supports either Redis, MongoDB, or a PostgreSQL database. Due to an unnecessarily strict conditional in the code handling the first step of the SSO process, the pre-existing logic that added (and later checked) a nonce was inadvertently rendered opt-in instead of opt-out. This re-exposed a vulnerability in that a specially crafted Man-in-the-Middle (MITM) attack could theoretically take over another user account during the single sign-on process. The issue has been fully patched in version 1.17.2.
Severity: nan (CVSS v3 base score: 7.5)
Weakness: CWE-352 \u2014 Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
src/routes/authentication.js
Commit message: fix: accidental unnecessarily strict conditional that effectively rendered SSO state checking opt-in instead of opt-out


Vulnerable code:
				if (strategy.checkState) {

Fixed code:
				if (strategy.checkState !== false) {
CVE-2022-3978 (JavaScript, published 2022-11-13T14:15Z)
Description: value: A vulnerability, which was classified as problematic, was found in NodeBB up to 2.5.7. This affects an unknown part of the file /register/abort. The manipulation leads to cross-site request forgery. It is possible to initiate the attack remotely. Upgrading to version 2.5.8 is able to address this issue. The name of the patch is 2f9d8c350e54543f608d3d4c8e1a49bbb6cdea38. It is recommended to upgrade the affected component. The associated identifier of this vulnerability is VDB-213555.
Severity: nan (CVSS v3 base score: 4.3)
Weakness: CWE-352 \u2014 Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
test/api.js
test/controllers.js
test/user.js
Commit message: fix: pass csrf_token into calls to /register/abort, #11017


Vulnerable code:
							uri: `${nconf.get('url')}/register/abort`,
			({ jar } = await helpers.loginUser('foo', 'barbar'));
				uri: `${nconf.get('url')}/register/abort`,
			({ jar } = await helpers.loginUser('updateprofile', '123456'));
				uri: `${nconf.get('url')}/register/abort`,

Fixed code:
							uri: `${nconf.get('url')}/register/abort?_csrf=${csrfToken}`,
		let csrf_token;

			({ jar, csrf_token } = await helpers.loginUser('foo', 'barbar'));
				uri: `${nconf.get('url')}/register/abort?_csrf=${csrf_token}`,
		let csrf_token;
			({ jar, csrf_token } = await helpers.loginUser('updateprofile', '123456'));
				uri: `${nconf.get('url')}/register/abort?_csrf=${csrf_token}`,
CVE-2022-46164 (JavaScript, published 2022-12-05T21:15Z)
Description: value: NodeBB is an open source Node.js based forum software. Due to a plain object with a prototype being used in socket.io message handling a specially crafted payload can be used to impersonate other users and takeover accounts. This vulnerability has been patched in version 2.6.1. Users are advised to upgrade. Users unable to upgrade may cherry-pick commit `48d143921753914da45926cca6370a92ed0c46b8` into their codebase to patch the exploit.

Severity: nan (CVSS v3 base score: 9.8)
Weakness: CWE-665 \u2014 Improper Initialization
The product does not initialize or incorrectly initializes a resource, which might leave the resource in an unexpected state when it is accessed or used.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
src/socket.io/index.js
Commit message: fix: prototype vulnerability in socket.io onMessage


Vulnerable code:
const Namespaces = {};

Fixed code:
const Namespaces = Object.create(null);
CVE-2023-26045 (JavaScript, published 2023-07-24T22:15Z)
Description: value: NodeBB is Node.js based forum software. Starting in version 2.5.0 and prior to version 2.8.7, due to the use of the object destructuring assignment syntax in the user export code path, combined with a path traversal vulnerability, a specially crafted payload could invoke the user export logic to arbitrarily execute javascript files on the local disk. This issue is patched in version 2.8.7. As a workaround, site maintainers can cherry pick the fix into their codebase to patch the exploit.
Severity: nan (CVSS v3 base score: 9.8)
Weakness: CWE-22 \u2014 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
src/api/users.js
src/socket.io/user/profile.js
Commit message: fix: object destructuring overwriting type parameter

also check for valid types in generateExport


Vulnerable code:
		api.users.generateExport(socket, { type, ...data });

Fixed code:
	const validTypes = ['profile', 'posts', 'uploads'];
	if (!validTypes.includes(type)) {
		throw new Error('[[error:invalid-data]]');
	}
		api.users.generateExport(socket, { type, uid: data.uid });
CVE-2023-2850 (JavaScript, published 2023-07-25T12:15Z)
Description: value: NodeBB is affected by a Cross-Site WebSocket Hijacking vulnerability due to missing validation of the request origin. Exploitation of this vulnerability allows certain user information to be extracted by attacker.
Severity: nan (CVSS v3 base score: 4.7)
Weakness: CWE-346 \u2014 Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
public/src/sockets.js
src/middleware/csrf.js
src/socket.io/index.js
test/helpers/index.js
test/socket.io.js
Commit message: poc: use csrf_token in ws handshake (#11573)



Vulnerable code:
		} else if (req.body.csrf_token) {
	io.use(authorize);

	socket.ip = (socket.request.headers['x-forwarded-for'] || socket.request.connection.remoteAddress || '').split(',')[0];
async function authorize(socket, callback) {
	const { request } = socket;


		request.session = sessionData;
		socket.uid = parseInt(sessionData.passport.user, 10);
	} else {
		socket.uid = 0;
	request.uid = socket.uid;
	callback();
helpers.connectSocketIO = function (res, callback) {
				helpers.connectSocketIO(res, (err, _io) => {

Fixed code:
		query: {
			_csrf: config.csrf_token,
		},
	isRequestValid,
		} else if (req.body && req.body.csrf_token) {
		} else if (req.query) {
			return req.query._csrf;
	isRequestValid,
		allowRequest: (req, callback) => {
			authorize(req, (err) => {
				if (err) {
					return callback(err);
				}
				const csrf = require('../middleware/csrf');
				const isValid = csrf.isRequestValid({
					session: req.session || {},
					query: req._query,
					headers: req.headers,
				});
				callback(null, isValid);
			});
		},
	socket.uid = socket.request.uid;
	socket.ip = (
		socket.request.headers['x-forwarded-for'] ||
		socket.request.connection.remoteAddress || ''
	).split(',')[0];
async function authorize(request, callback) {
	request.session = sessionData;
	let uid = 0;
		uid = parseInt(sessionData.passport.user, 10);
	request.uid = uid;
	callback(null, uid);
helpers.connectSocketIO = function (res, csrf_token, callback) {
		query: {
			_csrf: csrf_token,
		},
				helpers.connectSocketIO(res, body.csrf_token, (err, _io) => {
CVE-2023-30591 (JavaScript, published 2023-09-29T06:15Z)
Description: value: Denial-of-service in NodeBB <= v2.8.10 allows unauthenticated attackers to trigger a crash, when invoking `eventName.startsWith()` or `eventName.toString()`, while processing Socket.IO messages via crafted Socket.IO messages containing array or object type for the event name respectively.
Severity: nan (CVSS v3 base score: 7.5)
Weakness: CWE-754 \u2014 Improper Check for Unusual or Exceptional Conditions
The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
loader.js
Commit message: fix: #11403, remove loader.js crash counter logic


Vulnerable code:
const Loader = {
	timesStarted: 0,
};
		if (code !== 0) {
			if (Loader.timesStarted < numProcs * 3) {
				Loader.timesStarted += 1;
				if (Loader.crashTimer) {
					clearTimeout(Loader.crashTimer);
				}
				Loader.crashTimer = setTimeout(() => {
					Loader.timesStarted = 0;
				}, 10000);
			} else {
				console.log(`${numProcs * 3} restarts in 10 seconds, most likely an error on startup. Halting.`);
				process.exit();
			}
		}


Fixed code:
const Loader = {};
CVE-2023-30591 (JavaScript, published 2023-09-29T06:15Z)
Description: value: Denial-of-service in NodeBB <= v2.8.10 allows unauthenticated attackers to trigger a crash, when invoking `eventName.startsWith()` or `eventName.toString()`, while processing Socket.IO messages via crafted Socket.IO messages containing array or object type for the event name respectively.
Severity: nan (CVSS v3 base score: 7.5)
Weakness: CWE-754 \u2014 Improper Check for Unusual or Exceptional Conditions
The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product.
Repository: https://github.com/NodeBB/NodeBB
Files changed:
src/socket.io/index.js
test/socket.io.js
Commit message: fix: don't crash if event name is not a string


Vulnerable code:
	const parts = eventName.toString().split('.');

Fixed code:
	if (typeof eventName !== 'string') {
		const escapedName = validator.escape(String(eventName));
		return callback({ message: `[[error:invalid-event, ${escapedName}]]` });
	}

	const parts = eventName.split('.');
	it('should return error for invalid eventName type', (done) => {
		const eventName = ['topics.loadMoreTags'];
		io.emit(eventName, function (err) {
			const eventAsString = String(eventName);
			assert.strictEqual(err.message, `[[error:invalid-event, ${eventAsString}]]`);
			done();
		});
	});