code
stringlengths
14
2.05k
label
int64
0
1
programming_language
stringclasses
7 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
98
description
stringlengths
36
379
url
stringlengths
36
48
label_name
stringclasses
2 values
const get = async (config, auth, className, objectId, restOptions, clientSDK, context) => { var restWhere = { objectId }; const query = await RestQuery({ method: RestQuery.Method.get, config, auth, className, restWhere, restOptions, clientSDK, context, }); return query.execute();...
1
TypeScript
CWE-670
Always-Incorrect Control Flow Implementation
The code contains a control flow path that does not reflect the algorithm that the path is intended to implement, leading to incorrect behavior any time this path is navigated.
https://cwe.mitre.org/data/definitions/670.html
safe
module.exports = async (ctx) => { const { subdomain } = ctx.params; if (!isValidHost(subdomain)) { throw Error('Invalid subdomain'); } const shopUrl = `https://${subdomain}.booth.pm`; let shopName; const items = []; for (let page = 1; page <= maxPages; page++) { const pageUr...
1
TypeScript
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
module.exports = async (ctx) => { const { column } = ctx.params; if (!isValidHost(column)) { throw Error('Invalid column'); } const link = `http://${column}.blog.caixin.com`; const feed_url = `${link}/feed`; const feed = await parser.parseURL(feed_url); const title = `财新博客 - ${/[^»]...
1
TypeScript
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
const domainValidation = (domain, ctx) => { if (!config.feature.allow_user_supply_unsafe_domain && !allowDomain.includes(domain)) { ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`); } };
1
TypeScript
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
module.exports = async (ctx) => { const pub = ctx.params.pub; const jrn = ctx.params.jrn; const host = `https://${pub}.scitation.org`; const jrnlUrl = `${host}/toc/${jrn}/current?size=all`; if (!isValidHost(pub)) { throw Error('Invalid pub'); } // use Puppeteer due to the obstacle b...
1
TypeScript
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
module.exports = async (ctx) => { const type = ctx.params.type ?? 'www'; if (!isValidHost(type)) { throw Error('Invalid type'); } const base_url = `https://${type}.solidot.org`; const response = await got({ method: 'get', url: base_url, }); const data = response.data...
1
TypeScript
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
appendTo: () => document.body, onCreate(instance) {
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
onCreate(instance) { const content = instance.props.content + $("#narrow-hotkey-tooltip-template").html(); instance.setContent(parse_html(content)); },
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
onCreate(instance) { instance.setContent( parse_html(render_narrow_tooltip({content: instance.props.content})), ); },
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
function renderFile( filename: string, data: DataObj, config?: PartialConfig, cb?: CallbackFn, ): Promise<string> | void { /* Here we have some function overloading. Essentially, the first 2 arguments to renderFile should always be the filename and data Express will call renderFile with (filename, data,...
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
function renderFile( filename: string, data: DataObj, config?: PartialConfig, cb?: CallbackFn ): Promise<string> | void { /* Here we have some function overloading. Essentially, the first 2 arguments to renderFile should always be the filename and data Express will call renderFile with (filename, data, ...
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
function getElementFromTemplate(template: UpdateFunctionWithMethods<unknown>): HTMLElement { const element = document.createElement("div"); template(document.body, element); return element; }
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
default: jest.requireActual("escape-string-regexp"), }));
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
export function highlightFilterElements( content: string | number | undefined, search: string | number | undefined ): UpdateFunctionWithMethods<unknown> { const text_content = content?.toString(); if ( text_content === "" || text_content === undefined || search === "" || ...
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
function getHTMLStringFromTemplate(template) { const element = document.createElement("div"); template({}, element); return element.innerHTML; }
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
function TuleapHighlightFilter() { function getHTMLStringFromTemplate(template) { const element = document.createElement("div"); template({}, element); return element.innerHTML; } return function (text, search) { if (text === null) { return null; } ...
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
export async function downloadKubectl(version: string): Promise<string> { let cachedToolpath = toolCache.find(kubectlToolName, version); let kubectlDownloadPath = ''; const arch = getKubectlArch(); if (!cachedToolpath) { try { kubectlDownloadPath = await toolCache.downloadTool(...
1
TypeScript
CWE-732
Incorrect Permission Assignment for Critical Resource
The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.
https://cwe.mitre.org/data/definitions/732.html
safe
fastify.addHook('onRequest', async (request, reply) => { // %71ueueとかでリクエストされたら困るため const url = decodeURI(request.url); if (url === bullBoardPath || url.startsWith(bullBoardPath + '/')) { const token = request.cookies.token; if (token == null) { reply.code(401); throw new Error('login requi...
1
TypeScript
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
safe
super(meta, paramDef, async (ps, me) => { const user = await this.usersRepository.findOneBy({ id: ps.userId }); if (user == null) { throw new Error('user not found'); } if (user.avatarId == null) return; await this.usersRepository.update(user.id, { avatar: null, avatarId: null, avata...
1
TypeScript
CWE-863
Incorrect Authorization
The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
safe
public connectChannel(id: string, params: any, channel: string, pong = false) { const channelService = this.channelsService.getChannelService(channel); if (channelService.requireCredential && this.user == null) { return; } if (this.token && ((channelService.kind && !this.token.permission.some(p => p === c...
1
TypeScript
CWE-285
Improper Authorization
The product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/285.html
safe
create: (id: string, connection: Connection) => Channel;
1
TypeScript
CWE-285
Improper Authorization
The product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/285.html
safe
session: randomUUID(), permission: permissions, }, user); return (res.body as misskey.entities.MiauthGenTokenResponse).token; };
1
TypeScript
CWE-285
Improper Authorization
The product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/285.html
safe
export function escape(val: Escapable | Escapable[], timeZone?: string, dialect?: string, format?: boolean): string; export function format(sql: string, values: unknown[], timeZone?: string, dialect?: string): string;
1
TypeScript
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
export function escapeId(val: string, forbidQualified?: boolean): string; export function escape(val: Escapable | Escapable[], timeZone?: string, dialect?: string, format?: boolean): string;
1
TypeScript
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
getTokenFromRequest: (req) => { if (req.headers['x-csrf-token']) { return req.headers['x-csrf-token']; } else if (req.body && req.body.csrf_token) { return req.body.csrf_token; } else if (req.query) { return req.query._csrf; } },
1
TypeScript
CWE-346
Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
safe
Origin: nconf.get('url'), Cookie: cookie, }, query: { _csrf: csrf_token, }, }); socket.on('connect', () => { callback(null, socket); }); socket.on('error', (err) => { callback(err); }); };
1
TypeScript
CWE-346
Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
safe
function getFirstHeader(req: http.IncomingMessage, headerName: string): string | undefined { const val = req.headers[headerName] return Array.isArray(val) ? val[0] : val }
1
TypeScript
CWE-346
Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
safe
export function ensureOrigin(req: express.Request, _?: express.Response, next?: express.NextFunction): void { if (!authenticateOrigin(req)) { throw new HttpError("Forbidden", HttpCode.Forbidden) } if (next) { next() } }
1
TypeScript
CWE-346
Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
safe
export function authenticateOrigin(req: express.Request): boolean { // A missing origin probably means the source is non-browser. Not sure we // have a use case for this but let it through. const originRaw = getFirstHeader(req, "origin") if (!originRaw) { return true } let origin: string try { o...
1
TypeScript
CWE-346
Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
safe
export const wsErrorHandler: express.ErrorRequestHandler = async (err, req, res, next) => { logger.error(`${err.message} ${err.stack}`) let statusCode = 500 if (errorHasStatusCode(err)) { statusCode = err.statusCode } else if (errorHasCode(err) && notFoundCodes.includes(err.code)) { statusCode = HttpCod...
1
TypeScript
CWE-346
Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
safe
export function splitOnFirstEquals(str: string): [string, string | undefined] { const split = str.split(/=(.+)?/, 2) return [split[0], split[1]] }
1
TypeScript
CWE-346
Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
safe
return new Promise<Websocket>((resolve, reject) => { ws.on("error", (err) => reject(err)) ws.on("open", () => resolve(ws)) })
1
TypeScript
CWE-346
Origin Validation Error
The product does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
safe
cwd: path.join(fixtures, 'merge'), commit: '82442c2405804d7aa44e7bedbc0b93bb17707626 || touch ci ||', }); expect(latestInfo.error).toBeInstanceOf(Error); });
1
TypeScript
CWE-77
Improper Neutralization of Special Elements used in a Command ('Command Injection')
The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/77.html
safe
return { error: new Error('Not a valid commit hash') }; } if (!isGit(thisPath)) { return {}; } try { const { stdout } = execa.commandSync(`git --no-pager show ${thisCommit} --summary`, { cwd }); const info = stdout .split('\n') .filter((entry) => entry.length !== 0); const mer...
1
TypeScript
CWE-77
Improper Neutralization of Special Elements used in a Command ('Command Injection')
The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/77.html
safe
function inspectFallback(val) { const domains = Object.keys(val); if (domains.length === 0) { return "[Object: null prototype] {}"; } let result = "[Object: null prototype] {\n"; Object.keys(val).forEach((domain, i) => { result += formatDomain(domain, val[domain]); if (i < domains.length - 1) { ...
1
TypeScript
CWE-1321
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.
https://cwe.mitre.org/data/definitions/1321.html
safe
removeAllCookies(cb) { this.idx = Object.create(null); return cb(null); }
1
TypeScript
CWE-1321
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.
https://cwe.mitre.org/data/definitions/1321.html
safe
function formatPath(pathName, pathValue) { const indent = " "; let result = `${indent}'${pathName}': [Object: null prototype] {\n`; Object.keys(pathValue).forEach((cookieName, i, cookieNames) => { const cookie = pathValue[cookieName]; result += ` ${cookieName}: ${cookie.inspect()}`; if (i < co...
1
TypeScript
CWE-1321
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.
https://cwe.mitre.org/data/definitions/1321.html
safe
putCookie(cookie, cb) { if (!this.idx[cookie.domain]) { this.idx[cookie.domain] = Object.create(null); } if (!this.idx[cookie.domain][cookie.path]) { this.idx[cookie.domain][cookie.path] = Object.create(null); } this.idx[cookie.domain][cookie.path][cookie.key] = cookie; cb(null); ...
1
TypeScript
CWE-1321
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.
https://cwe.mitre.org/data/definitions/1321.html
safe
constructor() { super(); this.synchronous = true; this.idx = Object.create(null); const customInspectSymbol = getCustomInspectSymbol(); if (customInspectSymbol) { this[customInspectSymbol] = this.inspect; } }
1
TypeScript
CWE-1321
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.
https://cwe.mitre.org/data/definitions/1321.html
safe
function formatDomain(domainName, domainValue) { const indent = " "; let result = `${indent}'${domainName}': [Object: null prototype] {\n`; Object.keys(domainValue).forEach((path, i, paths) => { result += formatPath(path, domainValue[path]); if (i < paths.length - 1) { result += ","; } resu...
1
TypeScript
CWE-1321
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.
https://cwe.mitre.org/data/definitions/1321.html
safe
? element.boundElementIds.map((id) => ({ type: "arrow", id })) : element.boundElements ?? [], updated: element.updated ?? getUpdatedTimestamp(), link: element.link ? normalizeLink(element.link) : null, locked: element.locked ?? false, };
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
export const isLocalLink = (link: string | null) => { return !!(link?.includes(location.origin) || link?.startsWith("/")); };
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
export const normalizeLink = (link: string) => { return sanitizeUrl(link); };
1
TypeScript
CWE-79
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.
https://cwe.mitre.org/data/definitions/79.html
safe
export async function git(path: string): Promise<BlameResult> { const blamedLines: { [line: string]: BlamedLine } = {}; const pathToGit: string = await which('git'); if (!existsSync(path)) { throw new Error(`File ${path} does not exist`); } const result = execa.sync(pathToGit, ['blame', '-w', path]); ...
1
TypeScript
CWE-88
Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
The product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string.
https://cwe.mitre.org/data/definitions/88.html
safe
measure() { graphqlSync({ schema, source }); },
1
TypeScript
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
name @stream(label: "streamLabel", initialCount: 1, extraArg: true) } `).toDeepEqual([ { message: 'Fields "name" conflict because they have differing stream directives. Use different aliases on the fields to fetch both if this was intentional.', locations: [ {...
1
TypeScript
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
function sameArguments( node1: FieldNode | DirectiveNode, node2: FieldNode | DirectiveNode, ): boolean { const args1 = node1.arguments; const args2 = node2.arguments; if (args1 === undefined || args1.length === 0) { return args2 === undefined || args2.length === 0; } if (args2 === undefined || args2....
1
TypeScript
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
function sameStreams( directives1: ReadonlyArray<DirectiveNode>, directives2: ReadonlyArray<DirectiveNode>, ): boolean { const stream1 = getStreamDirective(directives1); const stream2 = getStreamDirective(directives2); if (!stream1 && !stream2) { // both fields do not have streams return true; } els...
1
TypeScript
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
function stringifyValue(value: ValueNode): string | null { return print(sortValueNode(value)); }
1
TypeScript
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
getVersion() { return '7.4.0'; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
setCipherKey(val, setup, modules) { this.cipherKey = val; if (this.cipherKey) { this.cryptoModule = setup.cryptoModule ?? setup.initCryptoModule({ cipherKey: this.cipherKey, useRandomIVs: this.useRandomIVs }); if (modules) modules.cryptoModule = this.cryptoModule; } return this; ...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function __processMessage(modules, message) { if (!modules.cryptoModule) return message; try { const decryptedData = modules.cryptoModule.decrypt(message); const decryptedPayload = decryptedData instanceof ArrayBuffer ? JSON.parse(new TextDecoder().decode(decryptedData)) : decryptedData; return de...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
handleResponse: async ({ PubNubFile, config, cryptography, cryptoModule }, res, params) => { let { body } = res.response; if (PubNubFile.supportsEncryptFile && (params.cipherKey || cryptoModule)) { body = params.cipherKey == null ? (await cryptoModule.decryptFile(PubNubFile.create({ da...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
const preparePayload = (modules, payload) => { let stringifiedPayload = JSON.stringify(payload); if (modules.cryptoModule) { const encrypted = modules.cryptoModule.encrypt(stringifiedPayload); stringifiedPayload = typeof encrypted === 'string' ? encrypted : encode(encrypted); stringifiedPayload = JSON.s...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function __processMessage(modules, message) { if (!modules.cryptoModule) return message; try { const decryptedData = modules.cryptoModule.decrypt(message); const decryptedPayload = decryptedData instanceof ArrayBuffer ? JSON.parse(new TextDecoder().decode(decryptedData)) : decryptedData; return de...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
function prepareMessagePayload(modules, messagePayload) { let stringifiedPayload = JSON.stringify(messagePayload); if (modules.cryptoModule) { const encrypted = modules.cryptoModule.encrypt(stringifiedPayload); stringifiedPayload = typeof encrypted === 'string' ? encrypted : encode(encrypted); stringif...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.decrypt = function (data, key) { if (typeof key === 'undefined' && cryptoModule) { const decrypted = modules.cryptoModule.decrypt(data); return decrypted instanceof ArrayBuffer ? encode(decrypted) : decrypted; } else { return crypto.decrypt(data, key); } };
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.encryptFile = function (key, file) { if (arguments.length == 1 && typeof key != 'string' && modules.cryptoModule) { file = key; return modules.cryptoModule.encryptFile(file, this.File); } return cryptography.encryptFile(key, file, this.File); };
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.setCipherKey = (key) => modules.config.setCipherKey(key, setup, modules);
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.encrypt = function (data, key) { if (typeof key === 'undefined' && modules.cryptoModule) { const encrypted = modules.cryptoModule.encrypt(data); return typeof encrypted === 'string' ? encrypted : encode(encrypted); } else { return crypto.encrypt(data, key); } };
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
this.decryptFile = function (key, file) { if (arguments.length == 1 && typeof key != 'string' && modules.cryptoModule) { file = key; return modules.cryptoModule.decryptFile(file, this.File); } return cryptography.decryptFile(key, file, this.File); };
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
constructor(configuration: { cipherKey: string }) { this.cipherKey = configuration.cipherKey; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
getKey() { const sha = createHash('sha256'); sha.update(Buffer.from(this.cipherKey, 'utf8')); return Buffer.from(sha.digest()); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get identifier() { return 'ACRH'; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
encryptedStream.stream.on('end', () => { if (aes) { aes.end(); } decryptedStream.end(); });
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: Buffer.concat([aes.update(bPlain), aes.final()]), };
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
getIv() { return randomBytes(AesCbcCryptor.BLOCK_SIZE); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get algo() { return 'aes-256-cbc'; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
const onReadable = () => { let data = encryptedStream.stream.read(); while (data !== null) { if (data) { const bChunk = Buffer.from(data); const sliceLen = encryptedStream.metadataLength - bIv.byteLength; if (bChunk.byteLength < sliceLen) { bIv = Buffer....
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
decrypt(encryptedData: EncryptedDataType) { const data = typeof encryptedData.data === 'string' ? encryptedData.data : encode(encryptedData.data); return this.cryptor.decrypt(data); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
async decryptFile(file: PubNubFileType, File: PubNubFileType) { return this.fileCryptor.decryptFile(this.config.cipherKey, file, File); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get identifier() { return ''; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
async encryptFile(file: PubNubFileType, File: PubNubFileType) { return this.fileCryptor.encryptFile(this.config.cipherKey, file, File); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: this.cryptor.encrypt(data), metadata: null, }; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
constructor(config: any) { this.config = config; this.cryptor = new Crypto({ config }); this.fileCryptor = new FileCryptor(); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get identifier() { return this._identifier; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
encrypt(data: ArrayBuffer | string) { const encrypted = this.defaultCryptor.encrypt(data); if (!encrypted.metadata) return encrypted.data; const header = CryptorHeader.from(this.defaultCryptor.identifier, encrypted.metadata); const headerData = new Uint8Array(header!.length); let pos = 0; he...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
constructor(cryptoModuleConfiguration: CryptoModuleConfiguration) { this.defaultCryptor = cryptoModuleConfiguration.default; this.cryptors = cryptoModuleConfiguration.cryptors ?? []; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
set identifier(value) { this._identifier = value; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get version() { return CryptorHeader.VERSION; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
cryptors: [new AesCbcCryptor({ cipherKey: config.cipherKey })], }); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
const cryptor = this.getAllCryptors().find((c) => id === c.identifier);
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
static tryGetMetadataSizeFromStream(stream: NodeJS.ReadableStream) { const sizeBuf = stream.read(1); if (sizeBuf && (sizeBuf[0] as number) < 255) { return sizeBuf[0] as number; } if ((sizeBuf[0] as number) === 255) { const nextBuf = stream.read(2); if (nextBuf.length >= 2) { ...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
private getAllCryptors() { return [this.defaultCryptor, ...this.cryptors]; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: Buffer.from(this.encrypt(file.data!) as Buffer), }); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
private getLegacyCryptor() { return this.getAllCryptors().find((c) => c.identifier === ''); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get data() { let pos = 0; const header = new Uint8Array(this.length); header.set(Buffer.from(CryptorHeader.SENTINEL)); pos += CryptorHeader.SENTINEL.length; header[pos] = this.version; pos++; if (this.identifier) header.set(Buffer.from(this.identifier), pos); pos += CryptorHeader.IDENT...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
static from(id: string, metadata: Buffer) { if (id === CryptorHeader.LEGACY_IDENTIFIER) return; return new CryptorHeaderV1(id, metadata.length); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
data: encryptedData.slice(header.length), metadata: metadata, }); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
static tryParse(encryptedData: Buffer) { let sentinel: any = ''; let version = null; if (encryptedData.length >= 4) { sentinel = encryptedData.slice(0, 4); if (sentinel.toString('utf8') !== CryptorHeader.SENTINEL) return ''; } if (encryptedData.length >= 5) { version = encrypted...
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
static validateVersion(data: number) { if (data && data > CryptorHeader.MAX_VERSION) throw new Error('decryption error. invalid header version'); return data; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
static tryGetIdentifier(data: Buffer) { if (data.byteLength < 4) { throw new Error('unknown cryptor error. decryption failed'); } else { return data.toString('utf8'); } }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get length() { return ( CryptorHeader.SENTINEL.length + 1 + CryptorHeader.IDENTIFIER_LENGTH + (this.metadataLength < 255 ? 1 : 3) + this.metadataLength ); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
static isSentinel(bytes: Buffer) { if (bytes && bytes.byteLength >= 4) { if (bytes.toString('utf8') == CryptorHeader.SENTINEL) return true; } }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
get metadataLength() { return this._metadataLength; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
new LegacyCryptor({ cipherKey: config.cipherKey, useRandomIVs: config.useRandomIVs ?? true, }), ], }); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
set metadataLength(value) { this._metadataLength = value; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
constructor(id: string, metadataLength: number) { this._identifier = id; this._metadataLength = metadataLength; }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
static withDefaultCryptor(defaultCryptor: CryptorType) { return new this({ default: defaultCryptor }); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe
constructor(configuration: { cipherKey: string }) { this.cipherKey = configuration.cipherKey; this.CryptoJS = cryptoJS; this.encryptedKey = this.CryptoJS.SHA256(this.cipherKey); }
1
TypeScript
CWE-331
Insufficient Entropy
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
https://cwe.mitre.org/data/definitions/331.html
safe