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 pageUrl = `${shopUrl}/items?page=${page}`; // eslint-disable-next-line no-await-in-loop const response = await got({ method: 'get', url: pageUrl, }); const data = response.data; const $ = cheerio.load(data); shopName = $('div.shop-name > span').text(); const pageItems = $('li.item'); if (pageItems.length === 0) { break; } for (let i = 0; i < pageItems.length; ++i) { const pageItem = pageItems[i]; // extract item name const itemName = $('h2.item-name > a', pageItem).text(); // extract item url const itemUrl = shopUrl + $('h2.item-name > a', pageItem).attr('href'); // extract item preview url const itemPreviewUrl = $('div.swap-image > img', pageItem).attr('src'); items.push({ title: itemName, description: `<img src='${itemPreviewUrl}'/>`, link: itemUrl, }); } } ctx.state.data = { title: shopName, link: shopUrl, description: shopName, allowEmpty: true, item: items, }; };
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 = `财新博客 - ${/[^»]*$/.exec(feed.title)[0]}`; const items = await Promise.all( feed.items.slice(0, 10).map(async (item, index) => { const link = item.link; const single = { title: item.title, pubDate: item.pubDate, link, author: item['dc:creator'], }; const other = await ctx.cache.tryGet(link, () => load(link, index === 0)); return Promise.resolve(Object.assign({}, single, other)); }) ); ctx.state.data = { title, link, description: items[0].feed_description, item: items, }; };
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 by cloudflare challenge const browser = await require('@/utils/puppeteer')(); const { jrnlName, list } = await ctx.cache.tryGet( jrnlUrl, async () => { const response = await puppeteerGet(jrnlUrl, browser); const $ = cheerio.load(response); const jrnlName = $('.header-journal-title').text(); const list = $('.card') .toArray() .map((item) => { $(item).find('.access-text').remove(); const title = $(item).find('.hlFld-Title').text(); const authors = $(item).find('.entryAuthor.all').text(); const img = $(item).find('img').attr('src'); const link = $(item).find('.ref.nowrap').attr('href'); const doi = link.replace('/doi/full/', ''); const description = renderDesc(title, authors, doi, img); return { title, link, doi, description, }; }); return { jrnlName, list, }; }, config.cache.routeExpire, false ); browser.close(); ctx.state.data = { title: jrnlName, link: jrnlUrl, item: list, allowEmpty: 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 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; // content is html format const $ = cheerio.load(data); // get urls const a = $('div.block_m').find('div.bg_htit > h2 > a'); const urls = []; for (let i = 0; i < a.length; ++i) { urls.push($(a[i]).attr('href')); } // get articles const msg_list = await Promise.all(urls.map((u) => ctx.cache.tryGet(u, () => get_article(u)))); // feed the data ctx.state.data = { title: '奇客的资讯,重要的东西', link: base_url, item: msg_list, }; };
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, cb) We also want to make (filename, data, options, cb) available */ let renderConfig: EtaConfigWithFilename; let callback: CallbackFn | undefined; data = data || {}; // First, assign our callback function to `callback` // We can leave it undefined if neither parameter is a function; // Callbacks are optional if (typeof cb === "function") { // The 4th argument is the callback callback = cb; } else if (typeof config === "function") { // The 3rd arg is the callback callback = config; } // If there is a config object passed in explicitly, use it if (typeof config === "object") { renderConfig = getConfig( (config as PartialConfig) || {}, ) as EtaConfigWithFilename; } else { // Otherwise, get the default config renderConfig = getConfig({}) as EtaConfigWithFilename; } // Set the filename option on the template // This will first try to resolve the file path (see getPath for details) renderConfig.filename = getPath(filename, renderConfig); return tryHandleCache(data, renderConfig, callback); }
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, cb) We also want to make (filename, data, options, cb) available */ let renderConfig: EtaConfigWithFilename; let callback: CallbackFn | undefined; data = data || {}; // First, assign our callback function to `callback` // We can leave it undefined if neither parameter is a function; // Callbacks are optional if (typeof cb === "function") { // The 4th argument is the callback callback = cb; } else if (typeof config === "function") { // The 3rd arg is the callback callback = config; } // If there is a config object passed in explicitly, use it if (typeof config === "object") { renderConfig = getConfig((config as PartialConfig) || {}) as EtaConfigWithFilename; } else { // Otherwise, get the default config renderConfig = getConfig({}) as EtaConfigWithFilename; } // Set the filename option on the template // This will first try to resolve the file path (see getPath for details) renderConfig.filename = getPath(filename, renderConfig); return tryHandleCache(data, renderConfig, callback); }
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 === "" || search === undefined ) { return html`${text_content}`; } const classifier = Classifier(search.toString()); const templates = classifier.classify(text_content).map((highlighted_text) => { if (!HighlightedText.isHighlight(highlighted_text)) { return html`${highlighted_text.content}`; } return html`<span class="highlight">${highlighted_text.content}</span>`; }); return html`${templates}`; }
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; } return getHTMLStringFromTemplate(highlightFilterElements(text, 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
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(getkubectlDownloadURL(version, arch)); } catch (exception) { if (exception instanceof toolCache.HTTPError && exception.httpStatusCode === 404) { throw new Error(util.format("Kubectl '%s' for '%s' arch not found.", version, arch)); } else { throw new Error('DownloadKubectlFailed'); } } cachedToolpath = await toolCache.cacheFile(kubectlDownloadPath, kubectlToolName + getExecutableExtension(), kubectlToolName, version); } const kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtension()); fs.chmodSync(kubectlPath, '775'); return kubectlPath; }
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 required'); } const user = await this.usersRepository.findOneBy({ token }); if (user == null) { reply.code(403); throw new Error('no such user'); } const isAdministrator = await this.roleService.isAdministrator(user); if (!isAdministrator) { reply.code(403); throw new Error('access denied'); } } });
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, avatarUrl: null, avatarBlurhash: null, }); this.moderationLogService.log(me, 'unsetUserAvatar', { userId: user.id, userUsername: user.username, userHost: user.host, fileId: user.avatarId, }); });
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 === channelService.kind)) || (!channelService.kind && channelService.requireCredential))) { return; } // 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視 if (channelService.shouldShare && this.channels.some(c => c.chName === channel)) { return; } const ch: Channel = channelService.create(id, this); this.channels.push(ch); ch.init(params ?? {}); if (pong) { this.sendMessageToWs('connected', { id: id, }); } }
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 { origin = new URL(originRaw).host.trim().toLowerCase() } catch (error) { return false // Malformed URL. } // Honor Forwarded if present. const forwardedRaw = getFirstHeader(req, "forwarded") if (forwardedRaw) { const parts = forwardedRaw.split(/[;,]/) for (let i = 0; i < parts.length; ++i) { const [key, value] = splitOnFirstEquals(parts[i]) if (key.trim().toLowerCase() === "host" && value) { return origin === value.trim().toLowerCase() } } } // Honor X-Forwarded-Host if present. const xHost = getFirstHeader(req, "x-forwarded-host") if (xHost) { return origin === xHost.trim().toLowerCase() } // A missing host likely means the reverse proxy has not been configured to // forward the host which means we cannot perform the check. Emit a warning // so an admin can fix the issue. const host = getFirstHeader(req, "host") if (!host) { logger.warn(`no host headers found; blocking request to ${req.originalUrl}`) return false } return origin === host.trim().toLowerCase() }
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 = HttpCode.NotFound } ;(req as WebsocketRequest).ws.end(`HTTP/1.1 ${statusCode} ${err.message}\r\n\r\n`) }
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 mergeIndex = info[1]?.indexOf('Merge') === -1 ? 0 : 1; const hash = (new RegExp(regex).exec(info[0]) || [])[1]; const shortHash = hash.slice(0, 7); const getInfo = (index: number): string | undefined => { const [, extractedInfo] = (new RegExp(regex).exec(info[index]) || []); return extractedInfo; }; const author = (getInfo(1 + mergeIndex)?.match(/([^<]+)/) || [])[1]?.trim(); const [, email] = getInfo(1 + mergeIndex)?.match(/<([^>]+)>/) || []; const date = getInfo(2 + mergeIndex); const message = stdout.split('\n\n')[1].trim(); return { hash, shortHash, commit: hash, shortCommit: shortHash, author, email, date, message, }; } catch (error) { return { 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
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) { result += ","; } result += "\n"; }); result += "}"; return result; }
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 < cookieNames.length - 1) { result += ","; } result += "\n"; }); result += `${indent}}`; return result; }
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 += ","; } result += "\n"; }); result += `${indent}}`; return result; }
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]); result.stdout.split('\n').forEach(line => { if (line !== '') { const blamedLine = convertStringToObject(line); if (blamedLine.line) { blamedLines[blamedLine.line] = blamedLine; } } }); return { [path]: blamedLines }; }
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: [ { line: 3, column: 9 }, { line: 4, column: 9 }, ], }, ]); });
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.length === 0) { return false; } if (args1.length !== args2.length) { return false; } const values2 = new Map(args2.map(({ name, value }) => [name.value, value])); return args1.every((arg1) => { const value1 = arg1.value; const value2 = values2.get(arg1.name.value); if (value2 === undefined) { return false; } return stringifyValue(value1) === stringifyValue(value2); }); }
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; } else if (stream1 && stream2) { // check if both fields have equivalent streams return sameArguments(stream1, stream2); } // fields have a mix of stream and no stream return false; }
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 decryptedPayload; } catch (e) { if (console && console.log) console.log('decryption error', e.message); return message; } }
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({ data: body, name: params.name }), PubNubFile)).data : await cryptography.decrypt(params.cipherKey ?? config.cipherKey, body); } return PubNubFile.create({ data: body, name: res.response.name ?? params.name, mimeType: res.response.type, }); },
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.stringify(stringifiedPayload); } return stringifiedPayload || ''; };
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 decryptedPayload; } catch (e) { if (console && console.log) console.log('decryption error', e.message); return message; } }
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); stringifiedPayload = JSON.stringify(stringifiedPayload); } return stringifiedPayload || ''; }
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.concat([bIv, bChunk]); } else { bIv = Buffer.concat([bIv, bChunk.slice(0, sliceLen)]); aes = createDecipheriv(this.algo, this.getKey(), bIv); aes.pipe(decryptedStream); aes.write(bChunk.slice(sliceLen)); } } data = encryptedStream.stream.read(); } };
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; headerData.set(header!.data, pos); pos = header!.length - encrypted.metadata.length; headerData.set(encrypted.metadata, pos); return Buffer.concat([headerData, Buffer.from(encrypted.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
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) { return new Uint16Array([nextBuf[0] as number, nextBuf[1] as number]).reduce((acc, val) => (acc << 8) + val, 0); } } throw new Error('decryption error. Invalid metadata 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
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.IDENTIFIER_LENGTH; const metadataLength = this.metadataLength; if (metadataLength < 255) { header[pos] = metadataLength; } else { header.set([255, metadataLength >> 8, metadataLength & 0xff], pos); } return header; }
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 = encryptedData[4]; } else { throw new Error('decryption error. invalid header version'); } if (version > CryptorHeader.MAX_VERSION) throw new Error('unknown cryptor error'); let identifier: Buffer; let pos = 5 + CryptorHeader.IDENTIFIER_LENGTH; if (encryptedData.length >= pos) { identifier = encryptedData.slice(5, pos); } else { throw new Error('decryption error. invalid crypto identifier'); } let metadataLength = null; if (encryptedData.length >= pos + 1) { metadataLength = encryptedData[pos]; } else { throw new Error('decryption error. invalid metadata length'); } pos += 1; if (metadataLength === 255 && encryptedData.length >= pos + 2) { metadataLength = new Uint16Array(encryptedData.slice(pos, pos + 2)).reduce((acc, val) => (acc << 8) + val, 0); pos += 2; } return new CryptorHeaderV1(identifier.toString('utf8'), 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 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