Dataset Viewer
Auto-converted to Parquet
messages
listlengths
3
3
metadata
dict
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\n#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)\n#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2016-0821, CWE-908\n\nFixed Code:\n```C\n#define LIST_POISON1 ((void *) 0x100 + POISON_POINTER_DELTA)\n#define LIST_POISON2 ((void *) 0x200 + POISON_POINTER_DELTA)\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2016-0821", "cwe_id": "CWE-908", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C++ code for security vulnerabilities:\n\n```C++\nunsigned const v_sym = get_te32(&dynp0[-1+ x_sym].d_val);\n if (!nbucket\n unsigned const v_sym = get_te32(&dynp0[-1+ x_sym].d_val);\n if (!n_bucket || !n_bitmask\n unsigned const v_sym = get_te32(&dynp0[-1+ x_sym].d_val);\n if (!nbucket\n upx_uint64_t const v_sym = get_te64(&dynp0[-1+ x_sym].d_val);\n if (!n_bucket || !n_bitmask\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2020-27787, NVD-CWE-noinfo\n\nFixed Code:\n```C++\nunsigned const v_sym = !x_sym ? 0 : get_te32(&dynp0[-1+ x_sym].d_val);\n if (!nbucket || !v_sym\n unsigned const v_sym = !x_sym ? 0 : get_te32(&dynp0[-1+ x_sym].d_val);\n if (!n_bucket || !n_bitmask || !v_sym\n unsigned const v_sym = !x_sym ? 0 : get_te32(&dynp0[-1+ x_sym].d_val);\n if (!nbucket || !v_sym\n upx_uint64_t const v_sym = !x_sym ? 0 : get_te64(&dynp0[-1+ x_sym].d_val);\n if (!n_bucket || !n_bitmask || !v_sym\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2020-27787", "cwe_id": "NVD-CWE-noinfo", "language": "C++", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this JavaScript code for security vulnerabilities:\n\n```JavaScript\nvar BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file' ];\n //\n var str = url.trim().toLowerCase();\n if (str.indexOf(':') >= 0 && BAD_PROTOCOLS.indexOf(str.split(':')[0]) >= 0) {\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2015-3295, CWE-284\n\nFixed Code:\n```JavaScript\n////////////////////////////////////////////////////////////////////////////////\n//\n// This validator does not pretent to functionality of full weight sanitizers.\n// It's a tradeoff between default security, simplicity and usability.\n// If you need different setup - override validator method as you wish. Or\n// replace it with dummy function and use external sanitizer.\n//\n\nvar BAD_PROTOCOLS = [ 'vbscript', 'javascript', 'file', 'data' ];\nvar ALLOWED_DATA_MIMES = [\n 'data:image/gif',\n 'data:image/png',\n 'data:image/jpeg',\n 'data:image/webp'\n];\n var str = url.trim().toLowerCase(),\n protocol = str.split(':')[0];\n\n if (str.indexOf(':') >= 0 && BAD_PROTOCOLS.indexOf(protocol) >= 0) {\n if (protocol === 'data' && ALLOWED_DATA_MIMES.indexOf(str.split(';')[0]) >= 0) {\n return true;\n }\n\n////////////////////////////////////////////////////////////////////////////////\n\n\nShould not allow data-uri except some whitelisted mimes\n.\n![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)\n.\n<p><img src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"\"></p>\n.\n\n.\n[xss link](data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K)\n.\n<p>[xss link](data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K)</p>\n.\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2015-3295", "cwe_id": "CWE-284", "language": "JavaScript", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\n* [php](http://en.wikipedia.org/wiki/PHP) (scripting language for dynamic web pages)\nstatic const l_int32 L_BUF_SIZE = 512;\nchar buf[L_BUF_SIZE];\n ret = sscanf(argv[i] + 1, \"prestring=%s\", buf);\n if ((len = strlen(buf)) > L_BUF_SIZE - 3) {\n ret = sscanf(argv[i] + 1, \"protos=%s\", buf);\n snprintf(buf, L_BUF_SIZE,\n snprintf(buf, L_BUF_SIZE, \"cpp -ansi -DNO_PROTOS %s %s\",\n * Utility for programmatic plotting using gnuplot 7.3.2 or later\n * ~ output to png (color), ps (mono), x11 (color), latex (mono)\nstatic const l_int32 L_BUF_SIZE = 512;\nchar buf[L_BUF_SIZE];\n snprintf(buf, L_BUF_SIZE, \"%s.cmd\", rootname);\n snprintf(buf, L_BUF_SIZE, \"%s.png\", newroot);\n snprintf(buf, L_BUF_SIZE, \"%s.ps\", newroot);\n snprintf(buf, L_BUF_SIZE, \"%s.eps\", newroot);\n snprintf(buf, L_BUF_SIZE, \"%s.tex\", newroot);\nchar buf[L_BUF_SIZE];\n snprintf(buf, L_BUF_SIZE, \"%s.data.%d\", gplot->rootname, gplot->nplots);\n snprintf(buf, L_BUF_SIZE, \"%f %f\\n\", valx, valy);\nchar buf[L_BUF_SIZE];\n snprintf(buf, L_BUF_SIZE, \"gnuplot %s\", cmdname);\n snprintf(buf, L_BUF_SIZE, \"wgnuplot %s\", cmdname);\nchar buf[L_BUF_SIZE];\n snprintf(buf, L_BUF_SIZE, \"set title '%s'\", gplot->title);\n snprintf(buf, L_BUF_SIZE, \"set xlabel '%s'\", gplot->xlabel);\n snprintf(buf, L_BUF_SIZE, \"set ylabel '%s'\", gplot->ylabel);\n snprintf(buf, L_BUF_SIZE, \"set terminal png; set output '%s'\",\n snprintf(buf, L_BUF_SIZE, \"set terminal postscript; set output '%s'\",\n snprintf(buf, L_BUF_SIZE,\n snprintf(buf, L_BUF_SIZE, \"set terminal latex; set output '%s'\",\n snprintf(buf, L_BUF_SIZE, \"set logscale x\");\n snprintf(buf, L_BUF_SIZE, \"set logscale y\");\n snprintf(buf, L_BUF_SIZE, \"plot '%s' title '%s' %s\",\n snprintf(buf, L_BUF_SIZE, \"plot '%s' title '%s' %s, \\\\\",\n snprintf(buf, L_BUF_SIZE, \" '%s' title '%s' %s, \\\\\",\n snprintf(buf, L_BUF_SIZE, \" '%s' title '%s' %s\",\nchar buf[L_BUF_SIZE];\n ignore = fscanf(fp, \"Rootname: %s\\n\", buf);\n ignores = fgets(buf, L_BUF_SIZE, fp); /* Title: ... */\n ignores = fgets(buf, L_BUF_SIZE, fp); /* X axis label: ... */\n ignores = fgets(buf, L_BUF_SIZE, fp); /* Y axis label: ... */\n ignore = fscanf(fp, \"Commandfile name: %s\\n\", buf);\n ignore = fscanf(fp, \"Output file name: %s\\n\", buf);\nchar typestr[128];\n if (fscanf(fp, \" Number of pts = %d; format = %s\\n\", &n, typestr) != 2)\nstatic const l_int32 L_BUF_SIZE = 256;\nchar combname[L_BUF_SIZE];\n snprintf(combname, L_BUF_SIZE, \"sel_comb_%dh\", size);\n snprintf(combname, L_BUF_SIZE, \"sel_comb_%dv\", size);\nchar buf[L_BUF_SIZE];\n snprintf(buf, L_BUF_SIZE,\nchar linebuf[L_BUF_SIZE];\n if (fgets(linebuf, L_BUF_SIZE, fp) == NULL)\n sscanf(linebuf, \" ------ %s ------\", selname);\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2018-7186, CWE-787\n\nFixed Code:\n```C\n* [OpenCV](https://github.com/opencv/opencv) (computer vision library)\n * [php](http://en.wikipedia.org/wiki/PHP) (scripting language for dynamic web pages)\nstatic const l_int32 L_BUFSIZE = 512; /* hardcoded below in sscanf() */\nchar buf[L_BUFSIZE];\n ret = sscanf(argv[i] + 1, \"prestring=%490s\", buf);\n if ((len = strlen(buf)) > L_BUFSIZE - 3) {\n ret = sscanf(argv[i] + 1, \"protos=%490s\", buf);\n snprintf(buf, L_BUFSIZE,\n snprintf(buf, L_BUFSIZE, \"cpp -ansi -DNO_PROTOS %s %s\",\n * Utility for programmatic plotting using gnuplot 4.6 or later\n * ~ output to png (color), ps and eps (mono), latex (mono)\nstatic const l_int32 L_BUFSIZE = 512; /* hardcoded below in fscanf */\nchar buf[L_BUFSIZE];\n snprintf(buf, L_BUFSIZE, \"%s.cmd\", rootname);\n snprintf(buf, L_BUFSIZE, \"%s.png\", newroot);\n snprintf(buf, L_BUFSIZE, \"%s.ps\", newroot);\n snprintf(buf, L_BUFSIZE, \"%s.eps\", newroot);\n snprintf(buf, L_BUFSIZE, \"%s.tex\", newroot);\nchar buf[L_BUFSIZE];\n snprintf(buf, L_BUFSIZE, \"%s.data.%d\", gplot->rootname, gplot->nplots);\n snprintf(buf, L_BUFSIZE, \"%f %f\\n\", valx, valy);\nchar buf[L_BUFSIZE];\n snprintf(buf, L_BUFSIZE, \"gnuplot %s\", cmdname);\n snprintf(buf, L_BUFSIZE, \"wgnuplot %s\", cmdname);\nchar buf[L_BUFSIZE];\n snprintf(buf, L_BUFSIZE, \"set title '%s'\", gplot->title);\n snprintf(buf, L_BUFSIZE, \"set xlabel '%s'\", gplot->xlabel);\n snprintf(buf, L_BUFSIZE, \"set ylabel '%s'\", gplot->ylabel);\n snprintf(buf, L_BUFSIZE, \"set terminal png; set output '%s'\",\n snprintf(buf, L_BUFSIZE, \"set terminal postscript; set output '%s'\",\n snprintf(buf, L_BUFSIZE,\n snprintf(buf, L_BUFSIZE, \"set terminal latex; set output '%s'\",\n snprintf(buf, L_BUFSIZE, \"set logscale x\");\n snprintf(buf, L_BUFSIZE, \"set logscale y\");\n snprintf(buf, L_BUFSIZE, \"plot '%s' title '%s' %s\",\n snprintf(buf, L_BUFSIZE, \"plot '%s' title '%s' %s, \\\\\",\n snprintf(buf, L_BUFSIZE, \" '%s' title '%s' %s, \\\\\",\n snprintf(buf, L_BUFSIZE, \" '%s' title '%s' %s\",\nchar buf[L_BUFSIZE];\n ignore = fscanf(fp, \"Rootname: %511s\\n\", buf); /* L_BUFSIZE - 1 */\n ignores = fgets(buf, L_BUFSIZE, fp); /* Title: ... */\n ignores = fgets(buf, L_BUFSIZE, fp); /* X axis label: ... */\n ignores = fgets(buf, L_BUFSIZE, fp); /* Y axis label: ... */\n ignore = fscanf(fp, \"Commandfile name: %511s\\n\", buf); /* L_BUFSIZE - 1 */\n ignore = fscanf(fp, \"Output file name: %511s\\n\", buf);\nchar typestr[128]; /* hardcoded below in fscanf */\n if (fscanf(fp, \" Number of pts = %d; format = %127s\\n\", &n, typestr) != 2)\nstatic const l_int32 L_BUFSIZE = 256; /* hardcoded below in sscanf */\nchar combname[L_BUFSIZE];\n snprintf(combname, L_BUFSIZE, \"sel_comb_%dh\", size);\n snprintf(combname, L_BUFSIZE, \"sel_comb_%dv\", size);\nchar buf[L_BUFSIZE];\n snprintf(buf, L_BUFSIZE,\nchar linebuf[L_BUFSIZE];\n if (fgets(linebuf, L_BUFSIZE, fp) == NULL)\n sscanf(linebuf, \" ------ %200s ------\", selname);\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2018-7186", "cwe_id": "CWE-787", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\n/*\n * helper function -- handles userspace copying for ioctl arguments\n * Obsolete usercopy function - Should be removed soon\n */\nlong\nvideo_usercopy(struct file *file, unsigned int cmd, unsigned long arg,\n\t\tv4l2_kioctl func)\n{\n\tchar\tsbuf[128];\n\tvoid *mbuf = NULL;\n\tvoid\t*parg = NULL;\n\tlong\terr = -EINVAL;\n\tint is_ext_ctrl;\n\tsize_t ctrls_size = 0;\n\tvoid __user *user_ptr = NULL;\n\n\tis_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||\n\t\t cmd == VIDIOC_TRY_EXT_CTRLS);\n\n\t/* Copy arguments into temp kernel buffer */\n\tswitch (_IOC_DIR(cmd)) {\n\tcase _IOC_NONE:\n\t\tparg = NULL;\n\t\tbreak;\n\tcase _IOC_READ:\n\tcase _IOC_WRITE:\n\tcase (_IOC_WRITE | _IOC_READ):\n\t\tif (_IOC_SIZE(cmd) <= sizeof(sbuf)) {\n\t\t\tparg = sbuf;\n\t\t} else {\n\t\t\t/* too big to allocate from stack */\n\t\t\tmbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);\n\t\t\tif (NULL == mbuf)\n\t\t\t\treturn -ENOMEM;\n\t\t\tparg = mbuf;\n\t\t}\n\n\t\terr = -EFAULT;\n\t\tif (_IOC_DIR(cmd) & _IOC_WRITE)\n\t\t\tif (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))\n\t\t\t\tgoto out;\n\t\tbreak;\n\t}\n\tif (is_ext_ctrl) {\n\t\tstruct v4l2_ext_controls *p = parg;\n\n\t\t/* In case of an error, tell the caller that it wasn't\n\t\t a specific control that caused it. */\n\t\tp->error_idx = p->count;\n\t\tuser_ptr = (void __user *)p->controls;\n\t\tif (p->count) {\n\t\t\tctrls_size = sizeof(struct v4l2_ext_control) * p->count;\n\t\t\t/* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */\n\t\t\tmbuf = kmalloc(ctrls_size, GFP_KERNEL);\n\t\t\terr = -ENOMEM;\n\t\t\tif (NULL == mbuf)\n\t\t\t\tgoto out_ext_ctrl;\n\t\t\terr = -EFAULT;\n\t\t\tif (copy_from_user(mbuf, user_ptr, ctrls_size))\n\t\t\t\tgoto out_ext_ctrl;\n\t\t\tp->controls = mbuf;\n\t\t}\n\t}\n\n\t/* call driver */\n\terr = func(file, cmd, parg);\n\tif (err == -ENOIOCTLCMD)\n\t\terr = -EINVAL;\n\tif (is_ext_ctrl) {\n\t\tstruct v4l2_ext_controls *p = parg;\n\n\t\tp->controls = (void *)user_ptr;\n\t\tif (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))\n\t\t\terr = -EFAULT;\n\t\tgoto out_ext_ctrl;\n\t}\n\tif (err < 0)\n\t\tgoto out;\n\nout_ext_ctrl:\n\t/* Copy results into user buffer */\n\tswitch (_IOC_DIR(cmd)) {\n\tcase _IOC_READ:\n\tcase (_IOC_WRITE | _IOC_READ):\n\t\tif (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))\n\t\t\terr = -EFAULT;\n\t\tbreak;\n\t}\n\nout:\n\tkfree(mbuf);\n\treturn err;\n}\nEXPORT_SYMBOL(video_usercopy);\n\nlong video_ioctl2(struct file *file,\n\t unsigned int cmd, unsigned long arg)\n\terr = __video_do_ioctl(file, cmd, parg);\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2010-5329, CWE-399\n\nFixed Code:\n```C\nlong\nvideo_usercopy(struct file *file, unsigned int cmd, unsigned long arg,\n\t v4l2_kioctl func)\n\terr = func(file, cmd, parg);\nEXPORT_SYMBOL(video_usercopy);\n\nlong video_ioctl2(struct file *file,\n\t unsigned int cmd, unsigned long arg)\n{\n\treturn video_usercopy(file, cmd, arg, __video_do_ioctl);\n}\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2010-5329", "cwe_id": "CWE-399", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nfor (pass = 0; pass < 10; pass++) {\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2015-4700, CWE-17\n\nFixed Code:\n```C\n/* JITed image shrinks with every pass and the loop iterates\n\t * until the image stops shrinking. Very large bpf programs\n\t * may converge on the last pass. In such case do one more\n\t * pass to emit the final image\n\t */\n\tfor (pass = 0; pass < 10 || image; pass++) {\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2015-4700", "cwe_id": "CWE-17", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\npipe->bufs = kzalloc(sizeof(struct pipe_buffer) * PIPE_DEF_BUFFERS, GFP_KERNEL);\n\t\t\tpipe->buffers = PIPE_DEF_BUFFERS;\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2016-2847, CWE-399\n\nFixed Code:\n```C\n- pipe-user-pages-hard\n- pipe-user-pages-soft\npipe-user-pages-hard:\n\nMaximum total number of pages a non-privileged user may allocate for pipes.\nOnce this limit is reached, no new pipes may be allocated until usage goes\nbelow the limit again. When set to 0, no limit is applied, which is the default\nsetting.\n\n==============================================================\n\npipe-user-pages-soft:\n\nMaximum total number of pages a non-privileged user may allocate for pipes\nbefore the pipe size gets limited to a single page. Once this limit is reached,\nnew pipes will be limited to a single page in size for this user in order to\nlimit total memory usage, and trying to increase them using fcntl() will be\ndenied until usage goes below the limit again. The default value allows to\nallocate up to 1024 pipes at their default size. When set to 0, no limit is\napplied.\n\n==============================================================\n\n/* Maximum allocatable pages per user. Hard limit is unset by default, soft\n * matches default values.\n */\nunsigned long pipe_user_pages_hard;\nunsigned long pipe_user_pages_soft = PIPE_DEF_BUFFERS * INR_OPEN_CUR;\n\nstatic void account_pipe_buffers(struct pipe_inode_info *pipe,\n unsigned long old, unsigned long new)\n{\n\tatomic_long_add(new - old, &pipe->user->pipe_bufs);\n}\n\nstatic bool too_many_pipe_buffers_soft(struct user_struct *user)\n{\n\treturn pipe_user_pages_soft &&\n\t atomic_long_read(&user->pipe_bufs) >= pipe_user_pages_soft;\n}\n\nstatic bool too_many_pipe_buffers_hard(struct user_struct *user)\n{\n\treturn pipe_user_pages_hard &&\n\t atomic_long_read(&user->pipe_bufs) >= pipe_user_pages_hard;\n}\n\n\t\tunsigned long pipe_bufs = PIPE_DEF_BUFFERS;\n\t\tstruct user_struct *user = get_current_user();\n\n\t\tif (!too_many_pipe_buffers_hard(user)) {\n\t\t\tif (too_many_pipe_buffers_soft(user))\n\t\t\t\tpipe_bufs = 1;\n\t\t\tpipe->bufs = kzalloc(sizeof(struct pipe_buffer) * pipe_bufs, GFP_KERNEL);\n\t\t}\n\n\t\t\tpipe->buffers = pipe_bufs;\n\t\t\tpipe->user = user;\n\t\t\taccount_pipe_buffers(pipe, 0, pipe_bufs);\n\t\tfree_uid(user);\n\taccount_pipe_buffers(pipe, pipe->buffers, 0);\n\tfree_uid(pipe->user);\n\taccount_pipe_buffers(pipe, pipe->buffers, nr_pages);\n\t\t} else if ((too_many_pipe_buffers_hard(pipe->user) ||\n\t\t\t too_many_pipe_buffers_soft(pipe->user)) &&\n\t\t !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) {\n\t\t\tret = -EPERM;\n\t\t\tgoto out;\n *\t@user: the user who created this pipe\n\tstruct user_struct *user;\nextern unsigned long pipe_user_pages_hard;\nextern unsigned long pipe_user_pages_soft;\n\tatomic_long_t pipe_bufs; /* how many pages are allocated in pipe buffers */\n\t{\n\t\t.procname\t= \"pipe-user-pages-hard\",\n\t\t.data\t\t= &pipe_user_pages_hard,\n\t\t.maxlen\t\t= sizeof(pipe_user_pages_hard),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= proc_doulongvec_minmax,\n\t},\n\t{\n\t\t.procname\t= \"pipe-user-pages-soft\",\n\t\t.data\t\t= &pipe_user_pages_soft,\n\t\t.maxlen\t\t= sizeof(pipe_user_pages_soft),\n\t\t.mode\t\t= 0644,\n\t\t.proc_handler\t= proc_doulongvec_minmax,\n\t},\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2016-2847", "cwe_id": "CWE-399", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nQInt8() {}\n QUInt8() {}\n QInt16() {}\n QUInt16() {}\n QInt32() {}\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2020-26266, CWE-908\n\nFixed Code:\n```C\nQInt8() : value(0) {}\n QUInt8() : value(0) {}\n QInt16() : value(0) {}\n QUInt16() : value(0) {}\n QInt32() : value(0) {}\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2020-26266", "cwe_id": "CWE-908", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this php code for security vulnerabilities:\n\n```php\n<?php\n/**\n * Gallery\n *\n * This file is licensed under the Affero General Public License version 3 or\n * later. See the COPYING file.\n *\n * @author Olivier Paroz <[email protected]>\n *\n * @copyright Olivier Paroz 2016\n */\n\nnamespace OCA\\Gallery\\Controller;\n\nuse OCP\\IRequest;\nuse OCP\\ILogger;\n\nuse OCP\\AppFramework\\Controller;\nuse OCP\\AppFramework\\Http;\n\nuse OCA\\Gallery\\Service\\ConfigService;\n\n/**\n * Class ConfigController\n *\n * @package OCA\\Gallery\\Controller\n */\nclass ConfigController extends Controller {\n\n\tuse Config;\n\tuse HttpError;\n\n\t/**\n\t * Constructor\n\t *\n\t * @param string $appName\n\t * @param IRequest $request\n\t * @param ConfigService $configService\n\t * @param ILogger $logger\n\t */\n\tpublic function __construct(\n\t\t$appName,\n\t\tIRequest $request,\n\t\tConfigService $configService,\n\t\tILogger $logger\n\t) {\n\t\tparent::__construct($appName, $request);\n\n\t\t$this->configService = $configService;\n\t\t$this->logger = $logger;\n\t}\n\n\t/**\n\t * @NoAdminRequired\n\t *\n\t * Returns an app configuration array\n\t *\n\t * @param bool $extramediatypes\n\t *\n\t * @return array <string,null|array>\n\t */\n\tpublic function get($extramediatypes = false) {\n\t\ttry {\n\t\t\treturn $this->getConfig($extramediatypes);\n\t\t} catch (\\Exception $exception) {\n\t\t\treturn $this->jsonError($exception);\n\t\t}\n\t}\n\n}\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-79)\n\nFixed Code:\n```php\n<?php\n/**\n * Gallery\n *\n * This file is licensed under the Affero General Public License version 3 or\n * later. See the COPYING file.\n *\n * @author Olivier Paroz <[email protected]>\n *\n * @copyright Olivier Paroz 2016\n */\n\nnamespace OCA\\Gallery\\Controller;\n\nuse OCP\\IRequest;\nuse OCP\\ILogger;\n\nuse OCP\\AppFramework\\Controller;\nuse OCP\\AppFramework\\Http;\n\nuse OCA\\Gallery\\Service\\ConfigService;\n\n/**\n * Class ConfigController\n *\n * @package OCA\\Gallery\\Controller\n */\nclass ConfigController extends Controller {\n\n\tuse Config;\n\tuse HttpError;\n\n\t/**\n\t * Constructor\n\t *\n\t * @param string $appName\n\t * @param IRequest $request\n\t * @param ConfigService $configService\n\t * @param ILogger $logger\n\t */\n\tpublic function __construct(\n\t\t$appName,\n\t\tIRequest $request,\n\t\tConfigService $configService,\n\t\tILogger $logger\n\t) {\n\t\tparent::__construct($appName, $request);\n\n\t\t$this->configService = $configService;\n\t\t$this->logger = $logger;\n\t}\n\n\t/**\n\t * @NoAdminRequired\n\t *\n\t * Returns an app configuration array\n\t *\n\t * @param bool $extramediatypes\n\t *\n\t * @return array <string,null|array>\n\t */\n\tpublic function get($extramediatypes = false) {\n\t\ttry {\n\t\t\treturn $this->getConfig($extramediatypes);\n\t\t} catch (\\Exception $exception) {\n\t\t\treturn $this->jsonError($exception, $this->request, $this->logger);\n\t\t}\n\t}\n\n}\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-79", "language": "php", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\n/* Ignore the errors thrown by the lexer. */\n if (context_p->error != PARSER_ERR_OUT_OF_MEMORY)\n {\n context_p->error = PARSER_ERR_NO_ERROR;\n }\n\n /* The following code may allocate memory, so it is enclosed in a try/catch. */\n PARSER_TRY (context_p->try_buffer)\n#if ENABLED (JERRY_ES2015)\n if (scanner_context.status_flags & SCANNER_CONTEXT_THROW_ERR_ASYNC_FUNCTION)\n JERRY_ASSERT (scanner_context.async_source_p != NULL);\n scanner_info_t *info_p;\n info_p = scanner_insert_info (context_p, scanner_context.async_source_p, sizeof (scanner_info_t));\n info_p->type = SCANNER_TYPE_ERR_ASYNC_FUNCTION;\n }\n#endif /* ENABLED (JERRY_ES2015) */\n while (scanner_context.active_literal_pool_p != NULL)\n scanner_pop_literal_pool (context_p, &scanner_context);\n PARSER_CATCH\n {\n JERRY_ASSERT (context_p->error == PARSER_ERR_NO_ERROR);\n }\n PARSER_TRY_END\n#if ENABLED (JERRY_ES2015)\n context_p->status_flags &= (uint32_t) ~PARSER_IS_GENERATOR_FUNCTION;\n#endif /* ENABLED (JERRY_ES2015) */\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2020-13649, CWE-754\n\nFixed Code:\n```C\nif (JERRY_UNLIKELY (context_p->error != PARSER_ERR_OUT_OF_MEMORY))\n /* Ignore the errors thrown by the lexer. */\n context_p->error = PARSER_ERR_NO_ERROR;\n\n /* The following code may allocate memory, so it is enclosed in a try/catch. */\n PARSER_TRY (context_p->try_buffer)\n #if ENABLED (JERRY_ES2015)\n if (scanner_context.status_flags & SCANNER_CONTEXT_THROW_ERR_ASYNC_FUNCTION)\n {\n JERRY_ASSERT (scanner_context.async_source_p != NULL);\n scanner_info_t *info_p;\n info_p = scanner_insert_info (context_p, scanner_context.async_source_p, sizeof (scanner_info_t));\n info_p->type = SCANNER_TYPE_ERR_ASYNC_FUNCTION;\n }\n #endif /* ENABLED (JERRY_ES2015) */\n while (scanner_context.active_literal_pool_p != NULL)\n {\n scanner_pop_literal_pool (context_p, &scanner_context);\n }\n }\n PARSER_CATCH\n JERRY_ASSERT (context_p->error == PARSER_ERR_OUT_OF_MEMORY);\n PARSER_TRY_END\n JERRY_ASSERT (context_p->error == PARSER_ERR_NO_ERROR || context_p->error == PARSER_ERR_OUT_OF_MEMORY);\n\n if (context_p->error == PARSER_ERR_OUT_OF_MEMORY)\n {\n parser_stack_free (context_p);\n return;\n }\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2020-13649", "cwe_id": "CWE-754", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Python code for security vulnerabilities:\n\n```Python\ndef test_accept_redirect_safe(self):\n \"/terms/accept/\", {\"terms\": 1, \"returnTo\": \"/secure/\"}, follow=True\n # Pre-accept terms 2 and 3\n UserTermsAndConditions.objects.create(user=self.user1, terms=self.terms2)\n UserTermsAndConditions.objects.create(user=self.user1, terms=self.terms3)\n LOGGER.debug(\"Test /terms/accept/contrib-terms/3/ post\")\n accept_response = self.client.post(\n \"/terms/accept/\", {\"terms\": 3, \"returnTo\": \"http://attacker/\"}, follow=False\n )\n return_to = self.request.GET.get(\"returnTo\", \"/\")\n return_url = request.POST.get(\"returnTo\", \"/\")\n parsed = urlparse(return_url)\n if parsed.hostname and parsed.hostname not in settings.ALLOWED_HOSTS:\n # Make sure the return url is a relative path or a trusted hostname\n return_url = '/'\n\n return_to = self.request.GET.get(\"returnTo\", \"/\")\n self.success_url = form.cleaned_data.get(\"returnTo\", \"/\") or \"/\"\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-4589, CWE-601\n\nFixed Code:\n```Python\ndef _post_accept(self, return_to):\n \"/terms/accept/\", {\"terms\": 1, \"returnTo\": return_to}, follow=True\n return accept_response\n\n def test_accept_redirect_safe(self):\n accept_response = self._post_accept(\"/secure/\")\n accept_response = self._post_accept(\"http://attacker/\")\n self.assertRedirects(accept_response, \"/\")\n def test_accept_redirect_unsafe_2(self):\n accept_response = self._post_accept(\"//attacker.com\")\n self.assertRedirects(accept_response, \"/\")\n\n def test_accept_redirect_unsafe_3(self):\n accept_response = self._post_accept(\"///attacker.com\")\n self.assertRedirects(accept_response, \"/\")\n\n def test_accept_redirect_unsafe_4(self):\n accept_response = self._post_accept(\"////attacker.com\")\nfrom django.utils.encoding import iri_to_uri\n def get_return_to(self, from_dict):\n return_to = from_dict.get(\"returnTo\", \"/\")\n\n if self.is_safe_url(return_to):\n # Django recommends to use this together with the helper above\n return iri_to_uri(return_to)\n\n LOGGER.debug(\"Unsafe URL found: {}\".format(return_to))\n return \"/\"\n\n def is_safe_url(self, url):\n # In Django 3.0 is_safe_url is renamed, so we import conditionally:\n # https://docs.djangoproject.com/en/3.2/releases/3.0/#id3\n try:\n from django.utils.http import url_has_allowed_host_and_scheme\n except ImportError:\n from django.utils.http import (\n is_safe_url as url_has_allowed_host_and_scheme,\n )\n\n return url_has_allowed_host_and_scheme(url, settings.ALLOWED_HOSTS)\n\n return_to = self.get_return_to(self.request.GET)\n return_url = self.get_return_to(self.request.POST)\n return_to = self.get_return_to(self.request.GET)\n self.success_url = self.get_return_to(form.cleaned_data)\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-4589", "cwe_id": "CWE-601", "language": "Python", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this php code for security vulnerabilities:\n\n```php\n<?php\n/**\n * 2007-2019 PrestaShop and Contributors\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the Open Software License (OSL 3.0)\n * that is bundled with this package in the file LICENSE.txt.\n * It is also available through the world-wide-web at this URL:\n * https://opensource.org/licenses/OSL-3.0\n * If you did not receive a copy of the license and are unable to\n * obtain it through the world-wide-web, please send an email\n * to [email protected] so we can send you a copy immediately.\n *\n * DISCLAIMER\n *\n * Do not edit or add to this file if you wish to upgrade PrestaShop to newer\n * versions in the future. If you wish to customize PrestaShop for your\n * needs please refer to https://www.prestashop.com for more information.\n *\n * @author PrestaShop SA <[email protected]>\n * @copyright 2007-2019 PrestaShop SA and Contributors\n * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)\n * International Registered Trademark & Property of PrestaShop SA\n */\n\nnamespace PrestaShopBundle\\EventListener;\n\nuse PrestaShop\\PrestaShop\\Core\\Util\\Url\\BackUrlProvider;\nuse Symfony\\Component\\HttpFoundation\\RedirectResponse;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent;\n\n/**\n * This class allows to redirect to back url.\n */\nfinal class BackUrlRedirectResponseListener\n{\n /**\n * @var BackUrlProvider\n */\n private $backUrlProvider;\n\n /**\n * @param BackUrlProvider $backUrlProvider\n */\n public function __construct(\n BackUrlProvider $backUrlProvider\n ) {\n $this->backUrlProvider = $backUrlProvider;\n }\n\n public function onKernelResponse(FilterResponseEvent $event)\n {\n $currentRequest = $event->getRequest();\n $originalResponse = $event->getResponse();\n\n if (!$originalResponse instanceof RedirectResponse) {\n return;\n }\n\n $backUrl = $this->backUrlProvider->getBackUrl($currentRequest);\n\n if ($backUrl && !$this->isRequestUrlEqualToResponseUrl($currentRequest, $originalResponse)) {\n $backUrlResponse = $originalResponse->setTargetUrl(urldecode($backUrl));\n $event->setResponse($backUrlResponse);\n }\n }\n\n /**\n * Compares if request url is equal to response url - in such case the back url should not work since the action\n * is suppose to be kept on the same url . E.g \"save and stay\" button click.\n *\n * @param Request $currentRequest\n * @param RedirectResponse $originalResponse\n *\n * @return bool\n */\n private function isRequestUrlEqualToResponseUrl(\n Request $currentRequest,\n RedirectResponse $originalResponse\n ) {\n return $currentRequest->getRequestUri() === $originalResponse->getTargetUrl();\n }\n}\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-601)\n\nFixed Code:\n```php\n<?php\n/**\n * 2007-2019 PrestaShop and Contributors\n *\n * NOTICE OF LICENSE\n *\n * This source file is subject to the Open Software License (OSL 3.0)\n * that is bundled with this package in the file LICENSE.txt.\n * It is also available through the world-wide-web at this URL:\n * https://opensource.org/licenses/OSL-3.0\n * If you did not receive a copy of the license and are unable to\n * obtain it through the world-wide-web, please send an email\n * to [email protected] so we can send you a copy immediately.\n *\n * DISCLAIMER\n *\n * Do not edit or add to this file if you wish to upgrade PrestaShop to newer\n * versions in the future. If you wish to customize PrestaShop for your\n * needs please refer to https://www.prestashop.com for more information.\n *\n * @author PrestaShop SA <[email protected]>\n * @copyright 2007-2019 PrestaShop SA and Contributors\n * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)\n * International Registered Trademark & Property of PrestaShop SA\n */\n\nnamespace PrestaShopBundle\\EventListener;\n\nuse Employee;\nuse PrestaShop\\PrestaShop\\Adapter\\LegacyContext;\nuse PrestaShop\\PrestaShop\\Core\\Util\\Url\\BackUrlProvider;\nuse Symfony\\Component\\HttpFoundation\\RedirectResponse;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent;\n\n/**\n * This class allows to redirect to back url.\n */\nfinal class BackUrlRedirectResponseListener\n{\n /**\n * @var BackUrlProvider\n */\n private $backUrlProvider;\n\n /**\n * @var int\n */\n private $employeeId;\n\n /**\n * @param BackUrlProvider $backUrlProvider\n */\n public function __construct(\n BackUrlProvider $backUrlProvider,\n LegacyContext $legacyContext\n ) {\n $this->backUrlProvider = $backUrlProvider;\n $context = $legacyContext->getContext();\n if (null !== $context && $context->employee instanceof Employee) {\n $this->employeeId = $context->employee->id;\n }\n }\n\n public function onKernelResponse(FilterResponseEvent $event)\n {\n // No need to continue because the employee is not connected\n if (empty($this->employeeId)) {\n return;\n }\n\n $currentRequest = $event->getRequest();\n $originalResponse = $event->getResponse();\n\n if (!$originalResponse instanceof RedirectResponse) {\n return;\n }\n\n $backUrl = $this->backUrlProvider->getBackUrl($currentRequest);\n\n if ($backUrl && !$this->isRequestUrlEqualToResponseUrl($currentRequest, $originalResponse)) {\n $backUrlResponse = $originalResponse->setTargetUrl(urldecode($backUrl));\n $event->setResponse($backUrlResponse);\n }\n }\n\n /**\n * Compares if request url is equal to response url - in such case the back url should not work since the action\n * is suppose to be kept on the same url . E.g \"save and stay\" button click.\n *\n * @param Request $currentRequest\n * @param RedirectResponse $originalResponse\n *\n * @return bool\n */\n private function isRequestUrlEqualToResponseUrl(\n Request $currentRequest,\n RedirectResponse $originalResponse\n ) {\n return $currentRequest->getRequestUri() === $originalResponse->getTargetUrl();\n }\n}\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-601", "language": "php", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Other code for security vulnerabilities:\n\n```Other\ndjango-email-verification~=0.1.0\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-2650, CWE-307\n\nFixed Code:\n```Other\n+\n #\n # Django Rest Framework SimpleJWT\n #\n SIMPLE_JWT['ACCESS_TOKEN_LIFETIME'] = timedelta(minutes=env.int(\"ACCESS_TOKEN_LIFETIME\", 15))\n SIMPLE_JWT['REFRESH_TOKEN_LIFETIME'] = timedelta(hours=env.int(\"REFRESH_TOKEN_LIFETIME\", 24))\n+SIMPLE_JWT['SIGNING_KEY'] = env.str(\"SIGNING_KEY\", SECRET_KEY)\n django-email-verification~=0.3.1\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-2650", "cwe_id": "CWE-307", "language": "Other", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Go code for security vulnerabilities:\n\n```Go\nif data[0] != '#' {\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2023-42821, CWE-125\n\nFixed Code:\n```Go\nif len(data) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\tif len(data) > 0 && data[0] != '#' {\n\n\t\tif len(citation) < 2 {\n\t\t\tcontinue\n\t\t}\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2023-42821", "cwe_id": "CWE-125", "language": "Go", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this PHP code for security vulnerabilities:\n\n```PHP\n<label for=\"var_ref_' + item.id + '\" class=\"control-label\">' + isRequired + item.name + '</label> \\\n <input type=\"text\" id=\"var_ref_' + item.id + '\" autocomplete=\"off\" name=\"environment[' + item.env_variable + ']\" class=\"form-control\" value=\"' + item.default_value + '\" /> \\\n <p class=\"text-muted small\">' + item.description + '<br /> \\\n <strong>Access in Startup:</strong> <code>{{' + item.env_variable + '}}</code><br /> \\\n <strong>Validation Rules:</strong> <code>' + item.rules + '</code></small></p> \\\n $('[data-attr=\"info-version\"]').html(data.version);\n $('[data-attr=\"info-system\"]').html(data.system.type + ' (' + data.system.arch + ') <code>' + data.system.release + '</code>');\n <h3 class=\"box-title\">' + isRequired + item.name + '</h3> \\\n <input name=\"environment[' + item.env_variable + ']\" class=\"form-control\" type=\"text\" id=\"egg_variable_' + item.env_variable + '\" /> \\\n <p class=\"no-margin small text-muted\">' + item.description + '</p> \\\n <p class=\"no-margin text-muted small\"><strong>Startup Command Variable:</strong> <code>' + item.env_variable + '</code></p> \\\n <p class=\"no-margin text-muted small\"><strong>Input Rules:</strong> <code>' + item.rules + '</code></p> \\\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2024-34067, NVD-CWE-noinfo\n\nFixed Code:\n```PHP\nfunction escapeHtml(str) {\n var div = document.createElement('div');\n div.appendChild(document.createTextNode(str));\n return div.innerHTML;\n }\n\n <label for=\"var_ref_' + escapeHtml(item.id) + '\" class=\"control-label\">' + isRequired + escapeHtml(item.name) + '</label> \\\n <input type=\"text\" id=\"var_ref_' + escapeHtml(item.id) + '\" autocomplete=\"off\" name=\"environment[' + escapeHtml(item.env_variable) + ']\" class=\"form-control\" value=\"' + escapeHtml(item.default_value) + '\" /> \\\n <p class=\"text-muted small\">' + escapeHtml(item.description) + '<br /> \\\n <strong>Access in Startup:</strong> <code>{{' + escapeHtml(item.env_variable) + '}}</code><br /> \\\n <strong>Validation Rules:</strong> <code>' + escapeHtml(item.rules) + '</code></small></p> \\\n function escapeHtml(str) {\n var div = document.createElement('div');\n div.appendChild(document.createTextNode(str));\n return div.innerHTML;\n }\n\n $('[data-attr=\"info-version\"]').html(escapeHtml(data.version));\n $('[data-attr=\"info-system\"]').html(escapeHtml(data.system.type) + ' (' + escapeHtml(data.system.arch) + ') <code>' + escapeHtml(data.system.release) + '</code>');\n function escapeHtml(str) {\n var div = document.createElement('div');\n div.appendChild(document.createTextNode(str));\n return div.innerHTML;\n }\n\n <h3 class=\"box-title\">' + isRequired + escapeHtml(item.name) + '</h3> \\\n <input name=\"environment[' + escapeHtml(item.env_variable) + ']\" class=\"form-control\" type=\"text\" id=\"egg_variable_' + escapeHtml(item.env_variable) + '\" /> \\\n <p class=\"no-margin small text-muted\">' + escapeHtml(item.description) + '</p> \\\n <p class=\"no-margin text-muted small\"><strong>Startup Command Variable:</strong> <code>' + escapeHtml(item.env_variable) + '</code></p> \\\n <p class=\"no-margin text-muted small\"><strong>Input Rules:</strong> <code>' + escapeHtml(item.rules) + '</code></p> \\\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2024-34067", "cwe_id": "NVD-CWE-noinfo", "language": "PHP", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Other code for security vulnerabilities:\n\n```Other\nif (pos < 0 || pos > *decoded_size) {\n debug_print(\"Position setting failed (%s)\\n\", decoded);\n return MOBI_DATA_CORRUPT;\n }\n if (l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {\n if (l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-1533, CWE-125\n\nFixed Code:\n```Other\n2022-04-27: Fix wrong boundary checks in inflections parser resulting in stack buffer over-read with corrupt input\n if (pos < 0 || l < 0 || d + l > decoded + INDX_INFLBUF_SIZEMAX) {\n if (pos < 0 || l < 0 || s + l > decoded + INDX_INFLBUF_SIZEMAX) {\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-1533", "cwe_id": "CWE-125", "language": "Other", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this PHP code for security vulnerabilities:\n\n```PHP\n$message->addString('(' . $local_import_file . ')');\n $message->addString('(' . $_FILES['import_file']['name'] . ')');\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2014-1879, CWE-79\n\nFixed Code:\n```PHP\n$message->addString('(' . htmlspecialchars($local_import_file) . ')');\n $message->addString('(' . htmlspecialchars($_FILES['import_file']['name']) . ')');\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2014-1879", "cwe_id": "CWE-79", "language": "PHP", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Python code for security vulnerabilities:\n\n```Python\n* Create proper symbolic link of chartkick.js on Ubuntu Jammy to fix loading of Charts in web interface\n self.getPage('/logout')\n self.getPage(\"/logout\")\n self.getPage('/logout/')\n self.getPage('/logout')\n self.getPage('/logout')\n self.getPage(\"/logout\")\n ('/logout', 303),\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <h6 class=\"dropdown-header\">{% trans %}Signed in as{% endtrans %} {{ username }}</h6>\n <a class=\"dropdown-item\" href=\"{{ url_for('prefs', 'general') }}\">{% trans %}Edit profile{% endtrans %}</a>\n <a class=\"dropdown-item\" href=\"{{ url_for('prefs', 'notification') }}\">{% trans %}Notifications{% endtrans %}</a>\n <div class=\"dropdown-divider\"></div>\n <a class=\"dropdown-item\" href=\"{{ url_for('logout') }}\">Logout</a>\n </div>\n <a class=\"btn-link btn-sm btn-block text-center\"\n href=\"{{ url_for('logout')}}\">\n {% trans %}Login with a different account{% endtrans %}\n </a>\n self.getPage(\"/logout\")\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-4646, CWE-352\n\nFixed Code:\n```Python\n* Create proper symbolic link of `chartkick.js` on Ubuntu Jammy to fix loading of Charts in web interface\n* Add CSRF verification on `/logout` credits to [reza.duty](https://rezaduty.me)\n self.getPage('/logout', method=\"POST\")\n self.getPage(\"/logout\", method=\"POST\")\n self.getPage('/logout', method=\"POST\")\n self.getPage('/logout', method=\"POST\")\n self.getPage('/logout', method=\"POST\")\n self.getPage(\"/logout\", method=\"POST\")\n ('/logout', 405),\n <form action=\"{{ url_for('logout') }}\" method=\"post\">\n <div aria-labelledby=\"navbarDropdown\" class=\"dropdown-menu\">\n <h6 class=\"dropdown-header\">{% trans %}Signed in as{% endtrans %} {{ username }}</h6>\n <a class=\"dropdown-item\" href=\"{{ url_for('prefs', 'general') }}\">{% trans %}Edit profile{% endtrans %}</a>\n <a class=\"dropdown-item\" href=\"{{ url_for('prefs', 'notification') }}\">{% trans %}Notifications{% endtrans %}</a>\n <div class=\"dropdown-divider\"></div>\n {# Logout button #}\n <button type=\"submit\" class=\"dropdown-item\">{% trans %}Logout{% endtrans %}</button>\n </div>\n </form>\n {# Logout button #}\n <form action=\"{{ url_for('logout') }}\" method=\"post\">\n <button type=\"submit\" class=\"btn btn-link btn-sm btn-block text-center\">\n {% trans %}Login with a different account{% endtrans %}\n </button>\n </form>\n self.getPage(\"/logout\", method=\"POST\")\n if request.method != 'POST':\n raise cherrypy.HTTPError(405)\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-4646", "cwe_id": "CWE-352", "language": "Python", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Other code for security vulnerabilities:\n\n```Other\nIPSECBASEVERSION=2.6.50\nopenswan (1:2.6.50-0xelerance1) trusty; urgency=low\n * Update to 2.6.50\nopenswan (1:2.6.50-0xelerance1) trusty; urgency=low\n * Update to 2.6.50\nVersion: 2.6.50\nVersion: 2.6.50\nVersion: 2.6.50\nVersion: 2.6.50\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2018-15836, CWE-347\n\nFixed Code:\n```Other\nv2.6.50.1 (August 24, 2018)\n\nThis release fixes CVE-2018-15836 (a Bleichenbacher-style signature\nforgery which involves RSA padding attack)\n\n* wo#7449 . test case for Bleichenbacher-style signature forgery [Bart Trojanowski]\n* wo#7449 . verify padding contents for IKEv2 RSA sig check [Bart Trojanowski]\n* wo#7449 . added lo06-verifybadsigs test case [Bart Trojanowski]\n* b01-install test case will no longer spam with the environment\n variables [Bart Trojanowski]\n* lp28-addrinfoserialize: IP address for moon changed to\n 192.139.46.82 [Bart Trojanowski]\n\nIPSECBASEVERSION=2.6.50.1\nopenswan (1:2.6.50.1-0xelerance1) trusty; urgency=low\n * Update to 2.6.50.1\nopenswan (1:2.6.50.1-0xelerance1) trusty; urgency=low\n * Update to 2.6.50.1\nVersion: 2.6.50.1\nVersion: 2.6.50.1\nVersion: 2.6.50.1\nVersion: 2.6.50.1\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2018-15836", "cwe_id": "CWE-347", "language": "Other", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this JavaScript code for security vulnerabilities:\n\n```JavaScript\nexpect(end[0].key).toEqual('strapi_content_types_schema');\n expect(end[0].key).toEqual('strapi_content_types_schema');\n privateAttributes: [],\nconst { hasDraftAndPublish, getPrivateAttributes } = require('@strapi/utils').contentTypes;\n Object.defineProperty(schema, 'privateAttributes', {\n get() {\n return getPrivateAttributes(schema);\n },\n });\n\n privateAttributes: [],\n return { kind: 'singleType', privateAttributes: [] };\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n privateAttributes: [],\n Object.assign(model, { privateAttributes: getPrivateAttributes(model) });\n Object.assign(model, { privateAttributes: getPrivateAttributes(model) });\n Object.assign(model, { privateAttributes: getPrivateAttributes(model) });\nconst { has } = require('lodash/fp');\n strapi.config.get('api.responses.privateAttributes', []),\n _.get(model, 'options.privateAttributes', []),\n return model?.privateAttributes?.includes(attributeName) ?? false;\n const isPrivate = isPrivateAttribute(schema, key) || attribute.private === true;\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2023-34093, CWE-200\n\nFixed Code:\n```JavaScript\nexpect(end[0].key).toEqual(original[0].key);\n expect(end[0].key).toEqual(original[0].key);\nconst { hasDraftAndPublish } = require('@strapi/utils').contentTypes;\n return { kind: 'singleType' };\nconst { getOr, has, union } = require('lodash/fp');\nconst getStoredPrivateAttributes = (model) => union(\n strapi?.config?.get('api.responses.privateAttributes', []) ?? [],\n getOr([], 'options.privateAttributes', model)\n);\n\n getStoredPrivateAttributes(model),\n if (model?.attributes?.[attributeName]?.private === true) {\n return true;\n }\n return getStoredPrivateAttributes(model).includes(attributeName);\n const isPrivate = attribute.private === true || isPrivateAttribute(schema, key);\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2023-34093", "cwe_id": "CWE-200", "language": "JavaScript", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this PHP code for security vulnerabilities:\n\n```PHP\n$results = $_POST['results'];\n$full_query = '';\n$query .= \" WHERE packages.device_id = devices.device_id AND packages.name LIKE '%\" . $_POST['package'] . \"%' $sql_where GROUP BY packages.name\";\n$full_query = $full_query . $query . \" LIMIT $start,$results\";\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2024-32461, NVD-CWE-noinfo\n\nFixed Code:\n```PHP\n$results = (int) $_POST['results_amount'];\n$query .= \" WHERE packages.device_id = devices.device_id AND packages.name LIKE ? $sql_where GROUP BY packages.name\";\n$param[] = '%' . $_POST['package'] . '%';\n$full_query = $query . \" LIMIT $start,$results\";\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2024-32461", "cwe_id": "NVD-CWE-noinfo", "language": "PHP", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this php code for security vulnerabilities:\n\n```php\n<!DOCTYPE html>\n<html>\n<head>\n\t<title><?php echo $layout['title'] ?></title>\n\t<meta charset=\"<?php echo CHARSET ?>\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n\t<meta name=\"robots\" content=\"noindex,nofollow\">\n\t<meta name=\"generator\" content=\"Bludit\">\n\n\t<!-- Favicon -->\n\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"<?php echo DOMAIN_ADMIN_THEME.'img/favicon.png?version='.BLUDIT_VERSION ?>\">\n\n\t<!-- CSS -->\n\t<?php\n\t\techo Theme::cssBootstrap();\n\t\techo Theme::css(array(\n\t\t\t'jquery-auto-complete.css',\n\t\t\t'open-iconic-bootstrap.min.css',\n\t\t\t'jquery.datetimepicker.min.css',\n\t\t\t'bludit.css'\n\t\t), DOMAIN_ADMIN_THEME_CSS);\n\t?>\n\n\t<!-- Javascript -->\n\t<?php\n\t\techo Theme::jquery();\n\t\techo Theme::jsBootstrap();\n\t\techo Theme::js(array(\n\t\t\t'jquery-auto-complete.min.js',\n\t\t\t'jquery.datetimepicker.full.min.js'\n\t\t), DOMAIN_ADMIN_THEME_JS);\n\t\techo Theme::jsSortable();\n\t?>\n\n\t<!-- Plugins -->\n\t<?php Theme::plugins('adminHead') ?>\n\n</head>\n<body class=\"h-100\">\n\n<!-- Plugins -->\n<?php Theme::plugins('adminBodyBegin') ?>\n\n<!-- Javascript dynamic generated by PHP -->\n<?php\n\techo '<script charset=\"utf-8\">'.PHP_EOL;\n\tinclude(PATH_CORE_JS.'variables.php');\n\techo '</script>'.PHP_EOL;\n\n\techo '<script charset=\"utf-8\">'.PHP_EOL;\n\tinclude(PATH_CORE_JS.'bludit-ajax.php');\n\techo '</script>'.PHP_EOL;\n?>\n\n<!-- Overlay background -->\n<div id=\"jsshadow\"></div>\n\n<!-- Alert -->\n<?php include('html/alert.php'); ?>\n\n<!-- Navbar, only for small devices -->\n<?php include('html/navbar.php'); ?>\n\n<div class=\"container h-100\">\n\t<!-- 25%/75% split on large devices, small, medium devices hide -->\n\t<div class=\"row h-100\">\n\n\t\t<!-- LEFT SIDEBAR - Display only on large devices -->\n\t\t<div class=\"sidebar col-lg-2 d-none d-lg-block\">\n\t\t<?php include('html/sidebar.php'); ?>\n\t\t</div>\n\n\t\t<!-- RIGHT MAIN -->\n\t\t<div class=\"col-lg-10 pt-3 pb-1 h-100\">\n\t\t<?php\n\t\t\tif (Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'].'.php')) {\n\t\t\t\tinclude(PATH_ADMIN_VIEWS.$layout['view'].'.php');\n\t\t\t} else {\n\t\t\t\techo '<h1 class=\"text-center\">'.$L->g('Page not found').'</h1>';\n\t\t\t\techo '<h2 class=\"text-center\">'.$L->g('Choose a page from the sidebar.').'</h2>';\n\t\t\t}\n\t\t?>\n\t\t</div>\n\t</div>\n</div>\n\n<!-- Check user logged and Internet connection -->\n<?php include('html/user-logged.php'); ?>\n\n<!-- Plugins -->\n<?php Theme::plugins('adminBodyEnd') ?>\n\n</body>\n</html>\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-94)\n\nFixed Code:\n```php\n<!DOCTYPE html>\n<html>\n<head>\n\t<title><?php echo $layout['title'] ?></title>\n\t<meta charset=\"<?php echo CHARSET ?>\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n\t<meta name=\"robots\" content=\"noindex,nofollow\">\n\t<meta name=\"generator\" content=\"Bludit\">\n\n\t<!-- Favicon -->\n\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"<?php echo HTML_PATH_CORE_IMG.'favicon.png?version='.BLUDIT_VERSION ?>\">\n\n\t<!-- CSS -->\n\t<?php\n\t\techo Theme::cssBootstrap();\n\t\techo Theme::css(array(\n\t\t\t'jquery-auto-complete.css',\n\t\t\t'open-iconic-bootstrap.min.css',\n\t\t\t'jquery.datetimepicker.min.css',\n\t\t\t'bludit.css'\n\t\t), DOMAIN_ADMIN_THEME_CSS);\n\t?>\n\n\t<!-- Javascript -->\n\t<?php\n\t\techo Theme::jquery();\n\t\techo Theme::jsBootstrap();\n\t\techo Theme::js(array(\n\t\t\t'jquery-auto-complete.min.js',\n\t\t\t'jquery.datetimepicker.full.min.js'\n\t\t), DOMAIN_ADMIN_THEME_JS);\n\t\techo Theme::jsSortable();\n\t?>\n\n\t<!-- Plugins -->\n\t<?php Theme::plugins('adminHead') ?>\n\n</head>\n<body class=\"h-100\">\n\n<!-- Plugins -->\n<?php Theme::plugins('adminBodyBegin') ?>\n\n<!-- Javascript dynamic generated by PHP -->\n<?php\n\techo '<script charset=\"utf-8\">'.PHP_EOL;\n\tinclude(PATH_CORE_JS.'variables.php');\n\techo '</script>'.PHP_EOL;\n\n\techo '<script charset=\"utf-8\">'.PHP_EOL;\n\tinclude(PATH_CORE_JS.'bludit-ajax.php');\n\techo '</script>'.PHP_EOL;\n?>\n\n<!-- Overlay background -->\n<div id=\"jsshadow\"></div>\n\n<!-- Alert -->\n<?php include('html/alert.php'); ?>\n\n<!-- Navbar, only for small devices -->\n<?php include('html/navbar.php'); ?>\n\n<div class=\"container h-100\">\n\t<!-- 25%/75% split on large devices, small, medium devices hide -->\n\t<div class=\"row h-100\">\n\n\t\t<!-- LEFT SIDEBAR - Display only on large devices -->\n\t\t<div class=\"sidebar col-lg-2 d-none d-lg-block\">\n\t\t<?php include('html/sidebar.php'); ?>\n\t\t</div>\n\n\t\t<!-- RIGHT MAIN -->\n\t\t<div class=\"col-lg-10 pt-3 pb-1 h-100\">\n\t\t<?php\n\t\t\tif (Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'].'.php')) {\n\t\t\t\tinclude(PATH_ADMIN_VIEWS.$layout['view'].'.php');\n\t\t\t} else {\n\t\t\t\techo '<h1 class=\"text-center\">'.$L->g('Page not found').'</h1>';\n\t\t\t\techo '<h2 class=\"text-center\">'.$L->g('Choose a page from the sidebar.').'</h2>';\n\t\t\t}\n\t\t?>\n\t\t</div>\n\t</div>\n</div>\n\n<!-- Check user logged and Internet connection -->\n<?php include('html/user-logged.php'); ?>\n\n<!-- Plugins -->\n<?php Theme::plugins('adminBodyEnd') ?>\n\n</body>\n</html>\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-94", "language": "php", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this javascript code for security vulnerabilities:\n\n```javascript\n// Copyright 2018 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Returns a error message for the given parameters.\n * @param {String} err error from the exec call.\n * @param {String} stderr standard error from the exec call.\n */\nconst getExecErrorMessage = (err, stderr) => {\n let errMsg = null;\n if (err) {\n errMsg = `exec error: ${err}`;\n } else if (stderr.length > 0) {\n errMsg = `stderr: ${stderr.toString()}`;\n }\n return errMsg;\n};\n\n\nmodule.exports = {\n getExecErrorMessage,\n};\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-78)\n\nFixed Code:\n```javascript\n// Copyright 2018 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nconst settings = require('./settings');\n\n/**\n * Returns a error message for the given parameters.\n * @param {String} err error from the exec call.\n * @param {String} stderr standard error from the exec call.\n */\nconst getExecErrorMessage = (err, stderr) => {\n let errMsg = null;\n if (err) {\n errMsg = `exec error: ${err}`;\n } else if (stderr.length > 0) {\n errMsg = `stderr: ${stderr.toString()}`;\n }\n return errMsg;\n};\n\n/**\n * Returns the original string with characters\n * specified in settings replaced with spaces.\n * @text {String} text to be replaced.\n */\nconst replaceCharactersWithSpaces = (text) => {\n const re = new RegExp(`[${settings.CHARACTERS_TO_REPLACE_WITH_SPACES}]`, 'g');\n const newText = text.replace(re, ' ').trim();\n return newText;\n};\n\nmodule.exports = {\n getExecErrorMessage,\n replaceCharactersWithSpaces,\n};\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-78", "language": "javascript", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this JavaScript code for security vulnerabilities:\n\n```JavaScript\nvar evtData = evt.data,\n\t\t\tdata = removeReservedKeywords( data );\n\t\t\tdata = protectSource( data, editor );\n\t\t\tdata = protectAttributes( data );\n\t\t\tdata = protectInsecureAttributes( data );\n\t\t\tdata = data.replace( new RegExp( 'data-cke-' + CKEDITOR.rnd + '-', 'ig' ), '' );\n\tfunction protectAttributes( html ) {\n\t\t\t\t\treturn ' data-cke-saved-' + fullAttr + ' data-cke-' + CKEDITOR.rnd + '-' + fullAttr;\n\tfunction protectInsecureAttributes( html ) {\n\t\treturn html.replace( /([^a-z0-9<\\-])(on\\w{3,})(?!>)/gi, '$1data-cke-' + CKEDITOR.rnd + '-$2' );\n\tfunction protectSource( data, editor ) {\n\t\t\ttempRegex = /<\\!--\\{cke_temp(comment)?\\}(\\d*?)-->/g;\n\t\t\treturn '<!--{cke_tempcomment}' + ( protectedHtml.push( match ) - 1 ) + '-->';\n\t\t\t\treturn ( /cke_temp(comment)?/ ).test( match ) ? match : '<!--{cke_temp}' + ( protectedHtml.push( match ) - 1 ) + '-->';\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-24728, CWE-79\n\nFixed Code:\n```JavaScript\nvar randomNumber = generateRandomNumber(),\n\t\t\t\tevtData = evt.data,\n\t\t\tdata = removeReservedKeywords( data, randomNumber );\n\t\t\tdata = protectSource( data, editor, randomNumber );\n\t\t\tdata = protectAttributes( data, randomNumber );\n\t\t\tdata = protectInsecureAttributes( data, randomNumber );\n\t\t\tdata = data.replace( new RegExp( 'data-cke-' + randomNumber + '-', 'ig' ), '' );\n\tfunction protectAttributes( html, randomNumber ) {\n\t\t\t\t\treturn ' data-cke-saved-' + fullAttr + ' data-cke-' + randomNumber + '-' + fullAttr;\n\tfunction protectInsecureAttributes( html, randomNumber ) {\n\t\treturn html.replace( /([^a-z0-9<\\-])(on\\w{3,})(?!>)/gi, '$1data-cke-' + randomNumber + '-$2' );\n\tfunction protectSource( data, editor, randomNumber ) {\n\t\t\ttempRegex = new RegExp('<\\\\!--\\\\{cke_temp_' + randomNumber + '(comment)?\\\\}(\\\\d*?)-->', 'g' );\n\t\t\treturn '<!--{cke_temp_' + randomNumber + 'comment}' + ( protectedHtml.push( match ) - 1 ) + '-->';\n\t\t\t\treturn ( tempRegex ).test( match ) ? match : '<!--{cke_temp_' + randomNumber + '}' +\n\t\t\t\t\t( protectedHtml.push( match ) - 1 ) + '-->';\n\n\tfunction generateRandomNumber() {\n\t\tvar cryptoApi = window.crypto || window.msCrypto;\n\n\t\tif ( cryptoApi ) {\n\t\t\treturn cryptoApi.getRandomValues( new Uint32Array( 1 ) )[ 0 ];\n\t\t}\n\n\t\treturn Math.floor( Math.random() * 9000000000 + 1000000000 );\n\t}\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-24728", "cwe_id": "CWE-79", "language": "JavaScript", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a DevOps security specialist.\n\nEXPERTISE: GitHub Actions, IaC security, least-privilege permissions\n\nTASK: Provide minimal security configuration fixes\n- Use platform-specific syntax (YAML, HCL)\n- Preserve functionality\n\nOUTPUT: Corrected configuration" }, { "role": "user", "content": "Rule: Ensure top-level permissions are not set to write-all\nSeverity: HIGH\nTool: checkov\nFile: .github/workflows/android-e2e-tests.yml\nConfig Type: github_actions\nMessage: Ensure top-level permissions are not set to write-all\n\nCurrent setup:\n permissions:\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the remediation, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Replace write-all with granular permissions\n\n```\npermissions:\n contents: read # For checking out implementation\n pull-requests: write # For commenting on PRs\n issues: write # For creating/updating issues\n # Remove: permissions: write-all\n```\n\n### Explanation\nUsing write-all grants excessive permissions. Specify only the permissions each job needs." } ]
{ "quality": "high", "source": "augmented", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "CKV2_GHA_1", "tool": "checkov", "security_category": "configuration_security", "confidence": 0.8, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": "semantic_paraphrase" }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: GHSA-6v67-2wr5-gvf4\nSeverity: CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:L/VI:N/VA:L/SC:H/SI:H/SA:H/V:D/U:Clear\nTool: osv-scanner\nPackage: ch.qos.logback:logback-core\nCurrent Version: 1.3.5\nFixed Version: 1.5.13, 1.3.15\nDescription: QOS.CH logback-core Server-Side Request Forgery vulnerability\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade ch.qos.logback:logback-core from 1.3.5 to 1.5.13\n\n```\nimplementation(\"ch.qos.logback:logback-core:1.5.13\")\n```\n\n### Explanation\nQOS.CH logback-core Server-Side Request Forgery vulnerability\n\n### Alternative Approaches\n\n\n**Alternative 1: Upgrade ch.qos.logback:logback-core from 1.3.5 to 1.3.15**\n\n```\nimplementation(\"ch.qos.logback:logback-core:1.3.15\")\n```\n\nAlternative fix for projects on different release branch (1.3.15 branch)" } ]
{ "quality": "high", "source": "generated", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "GHSA-6v67-2wr5-gvf4", "tool": "osv-scanner", "security_category": "dependency_vulnerabilities", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nSTRCPY(d, \"/\\\\\\\\\");\n\t STRCPY(d + 3, arg + 1);\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2021-4019, CWE-122\n\nFixed Code:\n```C\nvim_snprintf((char *)d, IOSIZE, \"/\\\\\\\\%s\", arg + 1);\nfunc Test_help_long_argument()\n try\n exe 'help \\%' .. repeat('0', 1021)\n catch\n call assert_match(\"E149:\", v:exception)\n endtry\nendfunc\n\n\n/**/\n 3669,\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2021-4019", "cwe_id": "CWE-122", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this c code for security vulnerabilities:\n\n```c\n/* Copyright 2011-2014 Autronica Fire and Security AS\n *\n * This program is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License as published by the Free\n * Software Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * Author(s):\n *\t2011-2014 Arvid Brodin, [email protected]\n */\n\n#ifndef __HSR_FRAMEREG_H\n#define __HSR_FRAMEREG_H\n\n#include \"hsr_main.h\"\n\nstruct hsr_node;\n\nstruct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[],\n\t\t\t u16 seq_out);\nstruct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,\n\t\t\t bool is_sup);\nvoid hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,\n\t\t\t struct hsr_port *port);\nbool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);\n\nvoid hsr_addr_subst_source(struct hsr_node *node, struct sk_buff *skb);\nvoid hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb,\n\t\t\t struct hsr_port *port);\n\nvoid hsr_register_frame_in(struct hsr_node *node, struct hsr_port *port,\n\t\t\t u16 sequence_nr);\nint hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,\n\t\t\t u16 sequence_nr);\n\nvoid hsr_prune_nodes(struct timer_list *t);\n\nint hsr_create_self_node(struct list_head *self_node_db,\n\t\t\t unsigned char addr_a[ETH_ALEN],\n\t\t\t unsigned char addr_b[ETH_ALEN]);\n\nvoid *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,\n\t\t\tunsigned char addr[ETH_ALEN]);\n\nint hsr_get_node_data(struct hsr_priv *hsr,\n\t\t const unsigned char *addr,\n\t\t unsigned char addr_b[ETH_ALEN],\n\t\t unsigned int *addr_b_ifindex,\n\t\t int *if1_age,\n\t\t u16 *if1_seq,\n\t\t int *if2_age,\n\t\t u16 *if2_seq);\n\n#endif /* __HSR_FRAMEREG_H */\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-772)\n\nFixed Code:\n```c\n/* Copyright 2011-2014 Autronica Fire and Security AS\n *\n * This program is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License as published by the Free\n * Software Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * Author(s):\n *\t2011-2014 Arvid Brodin, [email protected]\n */\n\n#ifndef __HSR_FRAMEREG_H\n#define __HSR_FRAMEREG_H\n\n#include \"hsr_main.h\"\n\nstruct hsr_node;\n\nvoid hsr_del_node(struct list_head *self_node_db);\nstruct hsr_node *hsr_add_node(struct list_head *node_db, unsigned char addr[],\n\t\t\t u16 seq_out);\nstruct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,\n\t\t\t bool is_sup);\nvoid hsr_handle_sup_frame(struct sk_buff *skb, struct hsr_node *node_curr,\n\t\t\t struct hsr_port *port);\nbool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);\n\nvoid hsr_addr_subst_source(struct hsr_node *node, struct sk_buff *skb);\nvoid hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb,\n\t\t\t struct hsr_port *port);\n\nvoid hsr_register_frame_in(struct hsr_node *node, struct hsr_port *port,\n\t\t\t u16 sequence_nr);\nint hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,\n\t\t\t u16 sequence_nr);\n\nvoid hsr_prune_nodes(struct timer_list *t);\n\nint hsr_create_self_node(struct list_head *self_node_db,\n\t\t\t unsigned char addr_a[ETH_ALEN],\n\t\t\t unsigned char addr_b[ETH_ALEN]);\n\nvoid *hsr_get_next_node(struct hsr_priv *hsr, void *_pos,\n\t\t\tunsigned char addr[ETH_ALEN]);\n\nint hsr_get_node_data(struct hsr_priv *hsr,\n\t\t const unsigned char *addr,\n\t\t unsigned char addr_b[ETH_ALEN],\n\t\t unsigned int *addr_b_ifindex,\n\t\t int *if1_age,\n\t\t u16 *if1_seq,\n\t\t int *if2_age,\n\t\t u16 *if2_seq);\n\n#endif /* __HSR_FRAMEREG_H */\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-772", "language": "c", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nif (s->width != avctx->width && s->height != avctx->height) {\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2017-7862, CWE-787\n\nFixed Code:\n```C\nif (s->width != avctx->width || s->height != avctx->height) {\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2017-7862", "cwe_id": "CWE-787", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this JavaScript code for security vulnerabilities:\n\n```JavaScript\nQUOTED = /\"((?:\\\\[\\x00-\\x7f]|[^\\x00-\\x08\\x0a-\\x1f\\x7f\"])*)\"/,\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2020-7662, NVD-CWE-Other\n\nFixed Code:\n```JavaScript\nQUOTED = /\"((?:\\\\[\\x00-\\x7f]|[^\\x00-\\x08\\x0a-\\x1f\\x7f\"\\\\])*)\"/,\n it(\"rejects a string missing its closing quote\", function() { with(this) {\n assertThrows(SyntaxError, function() {\n parse('foo; bar=\"fooa\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a\\\\a')\n })\n }})\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2020-7662", "cwe_id": "NVD-CWE-Other", "language": "JavaScript", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this PHP code for security vulnerabilities:\n\n```PHP\nif ($targetPath) {\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2023-5375, CWE-601\n\nFixed Code:\n```PHP\nif ($targetPath && $this->isLocalUrl($request, $targetPath)) {\n\n protected function isLocalUrl(Request $request, $url): bool\n {\n // If the first character is a slash, the URL is relative (only the path) and is local\n if (str_starts_with($url, '/')) {\n return true;\n }\n\n // If the URL is absolute but starts with the host of mosparo, we can redirect it.\n // Add the slash to prevent a redirect when a similar top-level domain is used.\n // For example, mosparo.com should not allow a redirect to mosparo.com.au\n if (str_starts_with($url, $request->getSchemeAndHttpHost() . '/')) {\n return true;\n }\n\n // The URL does not match the two checks because it's an external URL; no redirect in that case.\n return false;\n }\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2023-5375", "cwe_id": "CWE-601", "language": "PHP", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this PHP code for security vulnerabilities:\n\n```PHP\n//if (!$modulo->isPrime()) {\n // throw new \\UnexpectedValueException('PrimeField requires a prime number be passed to the constructor');\n //}\n $i = clone $one;\n\n while (!$t->powMod($two->pow($i), static::$modulo[$this->instanceID])->equals($one)) {\n $i = $i->add($one);\n if ($i->compare($m) >= 0) {\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2023-27560, CWE-835\n\nFixed Code:\n```PHP\nif (!$modulo->isPrime()) {\n throw new \\UnexpectedValueException('PrimeField requires a prime number be passed to the constructor');\n }\n for ($i == clone $one; $i->compare($m) < 0; $i = $i->add($one)) {\n if ($t->powMod($two->pow($i), static::$modulo[$this->instanceID])->equals($one)) {\n break;\n }\n if ($i->compare($m) == 0) {\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2023-27560", "cwe_id": "CWE-835", "language": "PHP", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nbitmap->length = DstWidth * DstHeight * GetBytesPerPixel(bitmap->format);\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2018-8787, CWE-190\n\nFixed Code:\n```C\nUINT32 size = DstWidth * DstHeight;\n\n\tif ((GetBytesPerPixel(bitmap->format) == 0) ||\n\t (DstWidth == 0) || (DstHeight == 0) || (DstWidth > UINT32_MAX / DstHeight) ||\n\t (size > (UINT32_MAX / GetBytesPerPixel(bitmap->format))))\n\t\treturn FALSE;\n\n\tsize *= GetBytesPerPixel(bitmap->format);\n\tbitmap->length = size;\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2018-8787", "cwe_id": "CWE-190", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this php code for security vulnerabilities:\n\n```php\n<?php\n // TODO : move all this to controller\n $okfiles = 0;\n $errfiles = 0;\n if (count($aErrorFilesInfo) == 0 && count($aImportedFilesInfo) > 0)\n {\n $status = gT(\"Success\");\n $class = '';\n $statusClass = 'text-success';\n $okfiles = count($aImportedFilesInfo);\n }\n elseif (count($aErrorFilesInfo) > 0 && count($aImportedFilesInfo) > 0)\n {\n $status = gT(\"Partial\");\n $class = 'message-box-warning';\n $statusClass = 'text-warning';\n $okfiles = count($aImportedFilesInfo);\n $errfiles = count($aErrorFilesInfo);\n }\n else\n {\n $status = gT(\"Error\");\n $statusClass = 'text-error';\n $class = 'message-box-error';\n $errfiles = count($aErrorFilesInfo);\n }\n?>\n<div class=\"row\">\n <div class=\"col-sm-11 col-sm-offset-1 content-right\">\n <!-- Message box from super admin -->\n <div class=\"jumbotron message-box <?php echo $class;?>\">\n <div class=\"h2\"><?php eT(\"Import theme result:\") ?></div>\n\n <p class='lead <?php echo $statusClass;?>'>\n <?php echo $status ?>\n </p>\n\n <p>\n <strong><u><?php eT(\"Resources import summary\") ?></u></strong><br />\n <?php echo gT(\"Files imported:\") . \" $okfiles\" ?><br />\n <?php echo gT(\"Files skipped:\") . \" $errfiles\" ?><br />\n </p>\n <p>\n <?php\n if (count($aImportedFilesInfo) > 0)\n {\n ?>\n <br /><strong><u><?php eT(\"Imported files:\") ?></u></strong><br />\n <ul style=\"max-height: 250px; overflow-y:scroll;\" class=\"list-unstyled\">\n <?php\n foreach ($aImportedFilesInfo as $entry)\n {\n if ($entry['is_folder']){\n ?>\n <li><?php echo gT(\"Folder:\") . \" \" . htmlspecialchars($entry[\"filename\"],ENT_QUOTES,'utf-8'); ?></li>\n <?php\n }\n else\n { ?>\n <li><?php echo gT(\"File:\") . \" \" . htmlspecialchars($entry[\"filename\"],ENT_QUOTES,'utf-8'); ?></li>\n\n\n <?php\n }\n }\n }\n if (count($aErrorFilesInfo) > 0)\n {\n ?>\n </ul>\n <br /><strong><u><?php eT(\"Skipped files:\") ?></u></strong><br />\n <ul style=\"max-height: 250px; overflow-y:scroll;\" class=\"list-unstyled\">\n <?php\n foreach ($aErrorFilesInfo as $entry)\n {\n ?>\n <li><?php echo gT(\"File:\") . \" \" . $entry[\"filename\"] ?></li>\n <?php\n }\n }\n ?>\n </ul>\n </p>\n <p>\n <input type='submit' class=\"btn btn-default btn-lg\" id=\"button-open-theme\" value='<?php eT(\"Open imported theme\") ?>' onclick=\"window.open('<?php echo $this->createUrl('admin/themes/sa/view/templatename/' . $newdir) ?>', '_top')\" />\n </p>\n </div>\n </div>\n</div>\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-79)\n\nFixed Code:\n```php\n<?php\n // TODO : move all this to controller\n $okfiles = 0;\n $errfiles = 0;\n if (count($aErrorFilesInfo) == 0 && count($aImportedFilesInfo) > 0)\n {\n $status = gT(\"Success\");\n $class = '';\n $statusClass = 'text-success';\n $okfiles = count($aImportedFilesInfo);\n }\n elseif (count($aErrorFilesInfo) > 0 && count($aImportedFilesInfo) > 0)\n {\n $status = gT(\"Partial\");\n $class = 'message-box-warning';\n $statusClass = 'text-warning';\n $okfiles = count($aImportedFilesInfo);\n $errfiles = count($aErrorFilesInfo);\n }\n else\n {\n $status = gT(\"Error\");\n $statusClass = 'text-error';\n $class = 'message-box-error';\n $errfiles = count($aErrorFilesInfo);\n }\n?>\n<div class=\"row\">\n <div class=\"col-sm-11 col-sm-offset-1 content-right\">\n <!-- Message box from super admin -->\n <div class=\"jumbotron message-box <?php echo $class;?>\">\n <div class=\"h2\"><?php eT(\"Import theme result:\") ?></div>\n\n <p class='lead <?php echo $statusClass;?>'>\n <?php echo $status ?>\n </p>\n\n <p>\n <strong><u><?php eT(\"Resources import summary\") ?></u></strong><br />\n <?php echo gT(\"Files imported:\") . \" $okfiles\" ?><br />\n <?php echo gT(\"Files skipped:\") . \" $errfiles\" ?><br />\n </p>\n <p>\n <?php\n if (count($aImportedFilesInfo) > 0)\n {\n ?>\n <br /><strong><u><?php eT(\"Imported files:\") ?></u></strong><br />\n <ul style=\"max-height: 250px; overflow-y:scroll;\" class=\"list-unstyled\">\n <?php\n foreach ($aImportedFilesInfo as $entry)\n {\n if ($entry['is_folder']){\n ?>\n <li><?php printf(gT(\"Folder: %s\"),CHtml::encode($entry[\"filename\"])); ?></li>\n <?php\n }\n else\n { ?>\n <li><?php printf(gT(\"File: %s\"),CHtml::encode($entry[\"filename\"])); ?></li>\n\n\n <?php\n }\n }\n }\n if (count($aErrorFilesInfo) > 0)\n {\n ?>\n </ul>\n <br /><strong><u><?php eT(\"Skipped files:\") ?></u></strong><br />\n <ul style=\"max-height: 250px; overflow-y:scroll;\" class=\"list-unstyled\">\n <?php\n foreach ($aErrorFilesInfo as $entry)\n {\n ?>\n <li><?php printf(gT(\"File: %s\"),CHtml::encode($entry[\"filename\"])); ?></li>\n <?php\n }\n }\n ?>\n </ul>\n </p>\n <p>\n <input type='submit' class=\"btn btn-default btn-lg\" id=\"button-open-theme\" value='<?php eT(\"Open imported theme\") ?>' onclick=\"window.open('<?php echo $this->createUrl('admin/themes/sa/view/templatename/' . $newdir) ?>', '_top')\" />\n </p>\n </div>\n </div>\n</div>\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-79", "language": "php", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: GHSA-4cx2-fc23-5wg6\nSeverity: CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/S:P/R:U/RE:M/U:Amber\nTool: osv-scanner\nPackage: org.bouncycastle:bcpkix-jdk18on\nCurrent Version: 1.78\nFixed Version: 1.79, 1.0.8, 2.0.8\nDescription: Bouncy Castle for Java bcpkix, bcprov, bcpkix-fips on All (API modules) allows Excessive Allocation\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade org.bouncycastle:bcpkix-jdk18on from 1.78 to 2.0.8\n\n```\nimplementation(\"org.bouncycastle:bcpkix-jdk18on:2.0.8\")\n```\n\n### Explanation\nBouncy Castle for Java bcpkix, bcprov, bcpkix-fips on All (API modules) allows Excessive Allocation\n\n### Alternative Approaches\n\n\n**Alternative 1: Upgrade org.bouncycastle:bcpkix-jdk18on from 1.78 to 1.79**\n\n```\nimplementation(\"org.bouncycastle:bcpkix-jdk18on:1.79\")\n```\n\nAlternative fix for projects on different release branch (1.79 branch)" } ]
{ "quality": "high", "source": "generated", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "GHSA-4cx2-fc23-5wg6", "tool": "osv-scanner", "security_category": "dependency_vulnerabilities", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nint length;\n\t\tif (precision == 0)\n\t\tif (trio_length(name) >= MAX_USER_NAME)\n\treturn strlen(string);\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2020-4030, CWE-125\n\nFixed Code:\n```C\nint length = 0;\n\t\tif (precision <= 0)\n\t\tif (trio_length_max(name, MAX_USER_NAME) >= MAX_USER_NAME)\n#include <limits.h>\n\treturn trio_length_max(string, INT_MAX);\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2020-4030", "cwe_id": "CWE-125", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this html code for security vulnerabilities:\n\n```html\n<div\n id=\"<?= $this->getId() ?>\"\n class=\"field-fileupload style-file-single <?= $singleFile ? 'is-populated' : '' ?> <?= $this->previewMode ? 'is-preview' : '' ?>\"\n data-control=\"fileupload\"\n data-template=\"#<?= $this->getId('template') ?>\"\n data-error-template=\"#<?= $this->getId('errorTemplate') ?>\"\n data-unique-id=\"<?= $this->getId() ?>\"\n <?php if ($useCaption): ?>data-config-handler=\"<?= $this->getEventHandler('onLoadAttachmentConfig') ?>\"<?php endif ?>\n <?php if ($acceptedFileTypes): ?>data-file-types=\"<?= $acceptedFileTypes ?>\"<?php endif ?>\n>\n\n <!-- Upload Button -->\n <button type=\"button\" class=\"btn btn-default upload-button\">\n <i class=\"icon-upload\"></i>\n </button>\n\n <!-- Existing file -->\n <div class=\"upload-files-container\">\n <?php if ($singleFile): ?>\n <div class=\"upload-object is-success\" data-id=\"<?= $singleFile->id ?>\" data-path=\"<?= $singleFile->pathUrl ?>\">\n <div class=\"icon-container\">\n <i class=\"icon-file\"></i>\n </div>\n <div class=\"info\">\n <h4 class=\"filename\">\n <span data-dz-name><?= $singleFile->title ?: $singleFile->file_name ?></span>\n </h4>\n <p class=\"size\"><?= e($singleFile->sizeToString()) ?></p>\n </div>\n <div class=\"meta\">\n <a\n href=\"javascript:;\"\n class=\"upload-remove-button\"\n data-request=\"<?= $this->getEventHandler('onRemoveAttachment') ?>\"\n data-request-confirm=\"<?= e(trans('backend::lang.fileupload.remove_confirm')) ?>\"\n data-request-data=\"file_id: <?= $singleFile->id ?>\"\n ><i class=\"icon-times\"></i></a>\n </div>\n </div>\n <?php endif ?>\n </div>\n\n <!-- Empty message -->\n <div class=\"upload-empty-message\">\n <span class=\"text-muted\"><?= $prompt ?></span>\n </div>\n\n</div>\n\n<!-- Template for new file -->\n<script type=\"text/template\" id=\"<?= $this->getId('template') ?>\">\n <div class=\"upload-object dz-preview dz-file-preview\">\n <div class=\"icon-container\">\n <i class=\"icon-file\"></i>\n <img data-dz-thumbnail />\n </div>\n <div class=\"info\">\n <h4 class=\"filename\">\n <span data-dz-name></span>\n </h4>\n <p class=\"size\" data-dz-size></p>\n </div>\n <div class=\"meta\">\n <a\n href=\"javascript:;\"\n class=\"upload-remove-button\"\n data-request=\"<?= $this->getEventHandler('onRemoveAttachment') ?>\"\n data-request-confirm=\"<?= e(trans('backend::lang.fileupload.remove_confirm')) ?>\"\n ><i class=\"icon-times\"></i></a>\n <div class=\"progress-bar\"><span class=\"upload-progress\" data-dz-uploadprogress></span></div>\n <div class=\"error-message\"><span data-dz-errormessage></span></div>\n </div>\n </div>\n</script>\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-79)\n\nFixed Code:\n```html\n<div\n id=\"<?= $this->getId() ?>\"\n class=\"field-fileupload style-file-single <?= $singleFile ? 'is-populated' : '' ?> <?= $this->previewMode ? 'is-preview' : '' ?>\"\n data-control=\"fileupload\"\n data-template=\"#<?= $this->getId('template') ?>\"\n data-error-template=\"#<?= $this->getId('errorTemplate') ?>\"\n data-unique-id=\"<?= $this->getId() ?>\"\n <?php if ($useCaption): ?>data-config-handler=\"<?= $this->getEventHandler('onLoadAttachmentConfig') ?>\"<?php endif ?>\n <?php if ($acceptedFileTypes): ?>data-file-types=\"<?= $acceptedFileTypes ?>\"<?php endif ?>\n>\n\n <!-- Upload Button -->\n <button type=\"button\" class=\"btn btn-default upload-button\">\n <i class=\"icon-upload\"></i>\n </button>\n\n <!-- Existing file -->\n <div class=\"upload-files-container\">\n <?php if ($singleFile): ?>\n <div class=\"upload-object is-success\" data-id=\"<?= $singleFile->id ?>\" data-path=\"<?= $singleFile->pathUrl ?>\">\n <div class=\"icon-container\">\n <i class=\"icon-file\"></i>\n </div>\n <div class=\"info\">\n <h4 class=\"filename\">\n <span data-dz-name><?= e($singleFile->title ?: $singleFile->file_name) ?></span>\n </h4>\n <p class=\"size\"><?= e($singleFile->sizeToString()) ?></p>\n </div>\n <div class=\"meta\">\n <a\n href=\"javascript:;\"\n class=\"upload-remove-button\"\n data-request=\"<?= $this->getEventHandler('onRemoveAttachment') ?>\"\n data-request-confirm=\"<?= e(trans('backend::lang.fileupload.remove_confirm')) ?>\"\n data-request-data=\"file_id: <?= $singleFile->id ?>\"\n ><i class=\"icon-times\"></i></a>\n </div>\n </div>\n <?php endif ?>\n </div>\n\n <!-- Empty message -->\n <div class=\"upload-empty-message\">\n <span class=\"text-muted\"><?= $prompt ?></span>\n </div>\n\n</div>\n\n<!-- Template for new file -->\n<script type=\"text/template\" id=\"<?= $this->getId('template') ?>\">\n <div class=\"upload-object dz-preview dz-file-preview\">\n <div class=\"icon-container\">\n <i class=\"icon-file\"></i>\n <img data-dz-thumbnail />\n </div>\n <div class=\"info\">\n <h4 class=\"filename\">\n <span data-dz-name></span>\n </h4>\n <p class=\"size\" data-dz-size></p>\n </div>\n <div class=\"meta\">\n <a\n href=\"javascript:;\"\n class=\"upload-remove-button\"\n data-request=\"<?= $this->getEventHandler('onRemoveAttachment') ?>\"\n data-request-confirm=\"<?= e(trans('backend::lang.fileupload.remove_confirm')) ?>\"\n ><i class=\"icon-times\"></i></a>\n <div class=\"progress-bar\"><span class=\"upload-progress\" data-dz-uploadprogress></span></div>\n <div class=\"error-message\"><span data-dz-errormessage></span></div>\n </div>\n </div>\n</script>\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-79", "language": "html", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nguint8 optlen; /* Option Length */\n NULL, 0x0, \"Optional Parameters Extension dedetected\", HFILL }},\n NULL, 0x0, \"Optional Parameters Extension dedetected\", HFILL }},\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2024-24478, NVD-CWE-noinfo\n\nFixed Code:\n```C\nuint16_t optlen; /* Option Length */\n NULL, 0x0, \"Optional Parameters Extension detected\", HFILL }},\n NULL, 0x0, \"Optional Parameters Extension detected\", HFILL }},\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2024-24478", "cwe_id": "NVD-CWE-noinfo", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this JavaScript code for security vulnerabilities:\n\n```JavaScript\nhandler: function ({command} = {}) {\n .then(() => this.reply(200));\n handler: function () {\n return this.reply(425);\n return this.reply(425);\n this.dataSocket.end(() => socket.destroy());\n return cmdFn()\n return cmdFn()\n expect(mockClient.reply.args[0][0]).to.equal(500);\n let mockConnection = {};\n before(() => {\n active = new ActiveConnector(mockConnection);\n });\n afterEach((done) => {\n server.close(done);\n it('destroys existing connection, then sets up a connection', function () {\n const destroyFnSpy = sandbox.spy(active.dataSocket, 'destroy');\n expect(destroyFnSpy.callCount).to.equal(1);\n expect(active.dataSocket).to.exist;\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2020-15152, CWE-918\n\nFixed Code:\n```JavaScript\nhandler: function ({log, command} = {}) {\n .then(() => this.reply(200))\n .catch((err) => {\n log.error(err);\n return this.reply(err.code || 425, err.message);\n });\n handler: function ({log}) {\n })\n .catch((err) => {\n log.error(err);\n return this.reply(err.code || 425, err.message);\n return this.reply(err.code || 425, err.message);\n return this.reply(err.code || 425, err.message);\nconst ip = require('ip');\nconst {SocketError} = require('../errors');\n if (!ip.isEqual(this.connection.commandSocket.remoteAddress, host)) {\n throw new SocketError('The given address is not yours', 500);\n }\n\n this.dataSocket.end(() => socket && socket.destroy());\n return cmdFn({})\n return cmdFn({})\n expect(mockClient.reply.args[0][0]).to.equal(501);\n let mockConnection = {\n commandSocket: {\n remoteAddress: '::ffff:127.0.0.1'\n }\n };\n active = new ActiveConnector(mockConnection);\n\n afterEach(() => {\n server.close();\n active.end();\n\n it('rejects alternative host', function () {\n return active.setupConnection('123.45.67.89', PORT)\n .catch((err) => {\n expect(err.code).to.equal(500);\n expect(err.message).to.equal('The given address is not yours');\n })\n .finally(() => {\n expect(active.dataSocket).not.to.exist;\n });\n });\n it('destroys existing connection, then sets up a connection', function () {\n const destroyFnSpy = sandbox.spy(active.dataSocket, 'destroy');\n\n return active.setupConnection(host, PORT)\n .then(() => {\n expect(destroyFnSpy.callCount).to.equal(1);\n expect(active.dataSocket).to.exist;\n });\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2020-15152", "cwe_id": "CWE-918", "language": "JavaScript", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "security flaw: CVE-2024-12798\nSeverity: MEDIUM\nTool: trivy\nPackage: ch.qos.logback:logback-core\nCurrent Version: 1.4.14\nFixed Version: 1.5.13, 1.3.15\nDescription: Package: ch.qos.logback:logback-core\nInstalled Version: 1.4.14\nVulnerability CVE-2024-12798\nSeverity: MEDIUM\nFixed Version: 1.5.13, 1.3.15\nLink: [CVE-2024-12798](https://avd.aquasec.com/nvd/cve-2024-12798)\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- implementation blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade ch.qos.logback:logback-core from 1.4.14 to 1.5.13 to fix security security flaw\n\n```\nimplementation(\"ch.qos.logback:logback-core:1.5.13\")\n```\n\n### Explanation\nThe currently installed version 1.4.14 of ch.qos.logback:logback-core is vulnerable. Upgrading to version 1.5.13 will resolve the issue.\n\n### Alternative Approaches\n\n\n**Alternative 1: Upgrade to 1.3.15 if on a different release branch**\n\n```\nimplementation(\"ch.qos.logback:logback-core:1.3.15\")\n```\n\nFor projects on a different release branch, upgrade to 1.3.15 which also includes the security fix." } ]
{ "quality": "high", "source": "augmented", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "CVE-2024-12798", "tool": "trivy", "security_category": "dependency_security", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": "semantic_paraphrase" }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this JavaScript code for security vulnerabilities:\n\n```JavaScript\nthis.customParsers = {}\n this.customParsers['application/json'] = new Parser(true, false, bodyLimit, this[kDefaultJsonParse])\n this.customParsers['text/plain'] = new Parser(true, false, bodyLimit, defaultPlainTextParser)\n this.customParsers[''] = parser\n this.customParsers[contentType] = parser\n return contentType in this.customParsers\n if (contentType === 'application/json') {\n return this.customParsers['application/json'] && this.customParsers['application/json'].fn !== this[kDefaultJsonParse]\n if (contentType === 'text/plain') {\n return this.customParsers['text/plain'] && this.customParsers['text/plain'].fn !== defaultPlainTextParser\n return contentType in this.customParsers\n if (contentType in this.customParsers) {\n return this.customParsers[contentType]\n const parser = this.customParsers[parserName]\n const parser = this.customParsers[parserRegExp]\n return this.customParsers['']\n this.customParsers = {}\n delete this.customParsers[contentType]\n Object.assign(contentTypeParser.customParsers, c.customParsers)\n t.equal(contentTypeParser.customParsers[''].fn, first)\n t.same(Object.keys(contentTypeParser.customParsers).length, 2)\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-39288, CWE-754\n\nFixed Code:\n```JavaScript\n// using a map instead of a plain object to avoid prototype hijack attacks\n this.customParsers = new Map()\n this.customParsers.set('application/json', new Parser(true, false, bodyLimit, this[kDefaultJsonParse]))\n this.customParsers.set('text/plain', new Parser(true, false, bodyLimit, defaultPlainTextParser))\n this.customParsers.set('', parser)\n this.customParsers.set(contentType.toString(), parser)\n return this.customParsers.has(typeof contentType === 'string' ? contentType : contentType.toString())\n if (contentType === 'application/json' && this.customParsers.has(contentType)) {\n return this.customParsers.get(contentType).fn !== this[kDefaultJsonParse]\n if (contentType === 'text/plain' && this.customParsers.has(contentType)) {\n return this.customParsers.get(contentType).fn !== defaultPlainTextParser\n return this.hasParser(contentType)\n if (this.hasParser(contentType)) {\n return this.customParsers.get(contentType)\n const parser = this.customParsers.get(parserName)\n const parser = this.customParsers.get(parserRegExp.toString())\n return this.customParsers.get('')\n this.customParsers = new Map()\n this.customParsers.delete(contentType.toString())\n contentTypeParser.customParsers = new Map(c.customParsers.entries())\n t.equal(contentTypeParser.customParsers.get('').fn, first)\n t.same(contentTypeParser.customParsers.size, 2)\n\ntest('Safeguard against malicious content-type / 1', async t => {\n const badNames = Object.getOwnPropertyNames({}.__proto__) // eslint-disable-line\n t.plan(badNames.length)\n\n const fastify = Fastify()\n\n fastify.post('/', async () => {\n return 'ok'\n })\n\n for (const prop of badNames) {\n const response = await fastify.inject({\n method: 'POST',\n path: '/',\n headers: {\n 'content-type': prop\n },\n body: ''\n })\n\n t.same(response.statusCode, 415)\n }\n})\n\ntest('Safeguard against malicious content-type / 2', async t => {\n t.plan(1)\n\n const fastify = Fastify()\n\n fastify.post('/', async () => {\n return 'ok'\n })\n\n const response = await fastify.inject({\n method: 'POST',\n path: '/',\n headers: {\n 'content-type': '\\\\u0063\\\\u006fnstructor'\n },\n body: ''\n })\n\n t.same(response.statusCode, 415)\n})\n\ntest('Safeguard against malicious content-type / 3', async t => {\n t.plan(1)\n\n const fastify = Fastify()\n\n fastify.post('/', async () => {\n return 'ok'\n })\n\n const response = await fastify.inject({\n method: 'POST',\n path: '/',\n headers: {\n 'content-type': 'constructor; charset=utf-8'\n },\n body: ''\n })\n\n t.same(response.statusCode, 415)\n})\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-39288", "cwe_id": "CWE-754", "language": "JavaScript", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Go code for security vulnerabilities:\n\n```Go\nhandler.HandleResponse(ctx, err, nil)\n\tName string `validate:\"required,gt=1,lte=128\" form:\"name\" json:\"name\"`\n\tShortDescription string `validate:\"omitempty,gt=3,lte=255\" form:\"short_description\" json:\"short_description\"`\n\tDescription string `validate:\"omitempty,gt=3,lte=2000\" form:\"description\" json:\"description\"`\n\tSiteUrl string `validate:\"required,gt=1,lte=512,url\" form:\"site_url\" json:\"site_url\"`\n\tContactEmail string `validate:\"required,gt=1,lte=512,email\" form:\"contact_email\" json:\"contact_email\"`\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2023-0934, CWE-79\n\nFixed Code:\n```Go\n\"github.com/microcosm-cc/bluemonday\"\nfunc Sanitizer(fl validator.FieldLevel) (res bool) {\n\tfield := fl.Field()\n\tswitch field.Kind() {\n\tcase reflect.String:\n\t\tfilter := bluemonday.UGCPolicy()\n\t\tfield.SetString(filter.Sanitize(field.String()))\n\t\treturn true\n\tcase reflect.Chan, reflect.Map, reflect.Slice, reflect.Array:\n\t\treturn field.Len() > 0\n\tcase reflect.Ptr, reflect.Interface, reflect.Func:\n\t\treturn !field.IsNil()\n\tdefault:\n\t\treturn field.IsValid() && field.Interface() != reflect.Zero(field.Type()).Interface()\n\t}\n}\n\n\t_ = validate.RegisterValidation(\"sanitizer\", Sanitizer)\n\thandler.HandleResponse(ctx, err, req)\n\tName string `validate:\"required,sanitizer,gt=1,lte=128\" form:\"name\" json:\"name\"`\n\tShortDescription string `validate:\"omitempty,sanitizer,gt=3,lte=255\" form:\"short_description\" json:\"short_description\"`\n\tDescription string `validate:\"omitempty,sanitizer,gt=3,lte=2000\" form:\"description\" json:\"description\"`\n\tSiteUrl string `validate:\"required,sanitizer,gt=1,lte=512,url\" form:\"site_url\" json:\"site_url\"`\n\tContactEmail string `validate:\"required,sanitizer,gt=1,lte=512,email\" form:\"contact_email\" json:\"contact_email\"`\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2023-0934", "cwe_id": "CWE-79", "language": "Go", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Scala code for security vulnerabilities:\n\n```Scala\nval tryFancySid = site.isFeatureEnabled(\"ffTryNewSid\", globals.config.featureFlags)\n val onlyFancySid = site.isFeatureEnabled(\"ffUseNewSid\", globals.config.featureFlags)\n val doUseFancySid = onlyFancySid || tryFancySid\n if (doUseFancySid) {\n val tryFancySid = site.isFeatureEnabled(\"ffTryNewSid\", globals.config.featureFlags)\n val onlyFancySid = site.isFeatureEnabled(\"ffUseNewSid\", globals.config.featureFlags)\n val doUseFancySid = onlyFancySid || tryFancySid\n if (doUseFancySid) {\n val tryFancySid = site.isFeatureEnabled(\"ffTryNewSid\", globals.config.featureFlags)\n val useFancySid = site.isFeatureEnabled(\"ffUseNewSid\", globals.config.featureFlags)\n if (tryFancySid || useFancySid) {\n val useOnlyFancySid = site.isFeatureEnabled(\"ffUseNewSid\", globals.config.featureFlags)\n val tryFancySid = site.isFeatureEnabled(\"ffTryNewSid\", globals.config.featureFlags)\n if (useOnlyFancySid || (tryFancySid && hasFancySid)) {\n debiki2.store_isFeatFlagOn(store, 'ffUseNewSid') ? 'TyCoSid123' : 'dwCoSid';\n if (debiki2.store_isFeatFlagOn(store, 'ffUseNewSid')) {\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2021-25981, CWE-613\n\nFixed Code:\n```Scala\nval useOldSid = site.isFeatureEnabled(\"ffUseOldSid\", globals.config.featureFlags)\n if (!useOldSid) {\n val useOldSid = site.isFeatureEnabled(\"ffUseOldSid\", globals.config.featureFlags)\n if (!useOldSid) {\n val useOldSid = site.isFeatureEnabled(\"ffUseOldSid\", globals.config.featureFlags)\n if (!useOldSid) {\n val useOldSid = site.isFeatureEnabled(\"ffUseOldSid\", globals.config.featureFlags)\n if (!useOldSid) {\n !debiki2.store_isFeatFlagOn(store, 'ffUseOldSid') ? 'TyCoSid123' : 'dwCoSid';\n const useNewSid = !debiki2.store_isFeatFlagOn(store, 'ffUseOldSid');\n if (useNewSid) {\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2021-25981", "cwe_id": "CWE-613", "language": "Scala", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: CVE-2024-12801\nSeverity: LOW\nTool: trivy\nPackage: ch.qos.logback:logback-core\nCurrent release: 1.4.14\nFixed Version: 1.5.13, 1.3.15\nDescription: Package: ch.qos.logback:logback-core\nInstalled Version: 1.4.14\nVulnerability CVE-2024-12801\nSeverity: LOW\nFixed Version: 1.5.13, 1.3.15\nLink: [CVE-2024-12801](https://avd.aquasec.com/nvd/cve-2024-12801)\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade ch.qos.logback:logback-core from 1.4.14 to 1.5.13 to fix security vulnerability\n\n```\nimplementation(\"ch.qos.logback:logback-core:1.5.13\")\n```\n\n### Explanation\nThe currently installed version 1.4.14 of ch.qos.logback:logback-core is vulnerable. Upgrading to version 1.5.13 will resolve the issue.\n\n### Alternative Approaches\n\n\n**Alternative 1: Upgrade to 1.3.15 if on a different release branch**\n\n```\nimplementation(\"ch.qos.logback:logback-core:1.3.15\")\n```\n\nFor projects on a different release branch, upgrade to 1.3.15 which also includes the security fix." } ]
{ "quality": "high", "source": "augmented", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "CVE-2024-12801", "tool": "trivy", "security_category": "dependency_security", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": "semantic_technical_detail" }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: CVE-2020-8908\nSeverity: LOW\nTool: trivy\nPackage: com.google.guava:guava\nCurrent Version: 31.1-jre\nFixed Version: 32.0.0-android\nDescription: Package: com.google.guava:guava\nInstalled Version: 31.1-jre\nVulnerability CVE-2020-8908\nSeverity: LOW\nFixed Version: 32.0.0-android\nLink: [CVE-2020-8908](https://avd.aquasec.com/nvd/cve-2020-8908)\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade com.google.guava:guava from 31.1-jre to 32.0.0-android to fix security security flaw\n\n```\nimplementation(\"com.google.guava:guava:32.0.0-android\")\n```\n\n### Explanation\nThe currently installed version 31.1-jre of com.google.guava:guava is vulnerable. Upgrading to version 32.0.0-android will resolve the issue." } ]
{ "quality": "high", "source": "augmented", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "CVE-2020-8908", "tool": "trivy", "security_category": "dependency_security", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": "semantic_paraphrase" }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this php code for security vulnerabilities:\n\n```php\n<?php\n/**\n * The WordPress version string\n *\n * @global string $wp_version\n */\n$wp_version = '4.8-alpha-40160';\n\n/**\n * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.\n *\n * @global int $wp_db_version\n */\n$wp_db_version = 38590;\n\n/**\n * Holds the TinyMCE version\n *\n * @global string $tinymce_version\n */\n$tinymce_version = '4403-20160901';\n\n/**\n * Holds the required PHP version\n *\n * @global string $required_php_version\n */\n$required_php_version = '5.2.4';\n\n/**\n * Holds the required MySQL version\n *\n * @global string $required_mysql_version\n */\n$required_mysql_version = '5.0';\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-863)\n\nFixed Code:\n```php\n<?php\n/**\n * The WordPress version string\n *\n * @global string $wp_version\n */\n$wp_version = '4.8-alpha-40169';\n\n/**\n * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.\n *\n * @global int $wp_db_version\n */\n$wp_db_version = 38590;\n\n/**\n * Holds the TinyMCE version\n *\n * @global string $tinymce_version\n */\n$tinymce_version = '4403-20160901';\n\n/**\n * Holds the required PHP version\n *\n * @global string $required_php_version\n */\n$required_php_version = '5.2.4';\n\n/**\n * Holds the required MySQL version\n *\n * @global string $required_mysql_version\n */\n$required_mysql_version = '5.0';\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-863", "language": "php", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Swift code for security vulnerabilities:\n\n```Swift\nmutating func set(value: URLQueryFragment, forPath path: [String]) {\n child.set(value: value, forPath: Array(path[1...]))\n result.set(value: .urlEncoded(value), forPath: [])\n result.set(value: .urlEncoded(value), forPath: try parseKey(key: Substring(key)))\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-31019, CWE-674\n\nFixed Code:\n```Swift\nlet maxRecursionDepth = 100\n mutating func set(value: URLQueryFragment, forPath path: [String], recursionDepth: Int) throws {\n guard recursionDepth <= maxRecursionDepth else {\n throw URLEncodedFormError.reachedNestingLimit\n }\n try child.set(value: value, forPath: Array(path[1...]), recursionDepth: recursionDepth + 1)\n case reachedNestingLimit\n case .reachedNestingLimit:\n return \"The data supplied is too nested\"\n try result.set(value: .urlEncoded(value), forPath: [], recursionDepth: 0)\n try result.set(value: .urlEncoded(value), forPath: try parseKey(key: Substring(key)), recursionDepth: 0)\n \n func testHeavilyNestedArray() throws {\n var body = \"x\"\n body += String(repeating: \"[]\", count: 80000)\n body += \"=y\"\n struct Foo: Content {}\n XCTAssertThrowsError(try URLEncodedFormDecoder().decode(Foo.self, from: body))\n XCTAssert(true, \"We should not have crashed\")\n }\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-31019", "cwe_id": "CWE-674", "language": "Swift", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Other code for security vulnerabilities:\n\n```Other\nKJ_REQUIRE(boundsCheck(segment, ptr, ptr +\n roundBitsUpToWords(ElementCount64(ref->listRef.elementCount()) * step)),\n return ListReader(segment, ptr, ref->listRef.elementCount(), step,\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2015-2312, CWE-400\n\nFixed Code:\n```Other\nBen Laurie <[email protected]>: discovered and responsibly disclosed security bugs\n KJ_ALWAYS_INLINE(bool amplifiedRead(WordCount virtualAmount));\n // Indicates that the reader should pretend that `virtualAmount` additional data was read even\n // though no actual pointer was traversed. This is used e.g. when reading a struct list pointer\n // where the element sizes are zero -- the sender could set the list size arbitrarily high and\n // cause the receiver to iterate over this list even though the message itself is small, so we\n // need to defend agaisnt DoS attacks based on this.\n\ninline bool SegmentReader::amplifiedRead(WordCount virtualAmount) {\n return readLimiter->canRead(virtualAmount, arena);\n}\n\nTEST(Encoding, VoidListAmplification) {\n MallocMessageBuilder builder;\n builder.initRoot<test::TestAnyPointer>().getAnyPointerField().initAs<List<Void>>(1u << 28);\n\n auto segments = builder.getSegmentsForOutput();\n EXPECT_EQ(1, segments.size());\n EXPECT_LT(segments[0].size(), 16); // quite small for such a big list!\n\n SegmentArrayMessageReader reader(builder.getSegmentsForOutput());\n auto root = reader.getRoot<test::TestAnyPointer>().getAnyPointerField();\n EXPECT_NONFATAL_FAILURE(root.getAs<List<TestAllTypes>>());\n\n MallocMessageBuilder copy;\n EXPECT_NONFATAL_FAILURE(copy.setRoot(reader.getRoot<AnyPointer>()));\n}\n\nTEST(Encoding, EmptyStructListAmplification) {\n MallocMessageBuilder builder;\n builder.initRoot<test::TestAnyPointer>().getAnyPointerField()\n .initAs<List<test::TestEmptyStruct>>(1u << 28);\n\n auto segments = builder.getSegmentsForOutput();\n EXPECT_EQ(1, segments.size());\n EXPECT_LT(segments[0].size(), 16); // quite small for such a big list!\n\n SegmentArrayMessageReader reader(builder.getSegmentsForOutput());\n auto root = reader.getRoot<test::TestAnyPointer>().getAnyPointerField();\n EXPECT_NONFATAL_FAILURE(root.getAs<List<TestAllTypes>>());\n}\n\n static KJ_ALWAYS_INLINE(bool amplifiedRead(SegmentReader* segment, WordCount virtualAmount)) {\n // If segment is null, this is an unchecked message, so we don't do read limiter checks.\n return segment == nullptr || segment->amplifiedRead(virtualAmount);\n }\n\n if (wordsPerElement * (1 * ELEMENTS) == 0 * WORDS) {\n // Watch out for lists of zero-sized structs, which can claim to be arbitrarily large\n // without having sent actual data.\n KJ_REQUIRE(amplifiedRead(srcSegment, elementCount * (1 * WORDS / ELEMENTS)),\n \"Message contains amplified list pointer.\") {\n goto useDefault;\n }\n }\n\n if (elementSize == ElementSize::VOID) {\n // Watch out for lists of void, which can claim to be arbitrarily large without having\n // sent actual data.\n KJ_REQUIRE(amplifiedRead(srcSegment, elementCount * (1 * WORDS / ELEMENTS)),\n \"Message contains amplified list pointer.\") {\n goto useDefault;\n }\n }\n\n if (wordsPerElement * (1 * ELEMENTS) == 0 * WORDS) {\n // Watch out for lists of zero-sized structs, which can claim to be arbitrarily large\n // without having sent actual data.\n KJ_REQUIRE(amplifiedRead(segment, size * (1 * WORDS / ELEMENTS)),\n \"Message contains amplified list pointer.\") {\n goto useDefault;\n }\n }\n\n ElementCount elementCount = ref->listRef.elementCount();\n WordCount wordCount = roundBitsUpToWords(ElementCount64(elementCount) * step);\n KJ_REQUIRE(boundsCheck(segment, ptr, ptr + wordCount),\n if (elementSize == ElementSize::VOID) {\n // Watch out for lists of void, which can claim to be arbitrarily large without having sent\n // actual data.\n KJ_REQUIRE(amplifiedRead(segment, elementCount * (1 * WORDS / ELEMENTS)),\n \"Message contains amplified list pointer.\") {\n goto useDefault;\n }\n }\n\n return ListReader(segment, ptr, elementCount, step,\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2015-2312", "cwe_id": "CWE-400", "language": "Other", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: CVE-2024-29025\nSeverity: MEDIUM\nTool: trivy\nPackage: io.netty:netty-codec-http\nCurrent Version: 4.1.106.Final\nFixed Version: 4.1.108.Final\nDescription: Package: io.netty:netty-codec-http\nInstalled Version: 4.1.106.Final\nVulnerability CVE-2024-29025\nSeverity: MEDIUM\nFixed Version: 4.1.108.Final\nLink: [CVE-2024-29025](https://avd.aquasec.com/nvd/cve-2024-29025)\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the remediation, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade io.netty:netty-codec-http from 4.1.106.Final to 4.1.108.Final to fix security security flaw\n\n```\nimplementation(\"io.netty:netty-codec-http:4.1.108.Final\")\n```\n\n### Explanation\nThe currently installed version 4.1.106.Final of io.netty:netty-codec-http is vulnerable. Upgrading to version 4.1.108.Final will resolve the issue." } ]
{ "quality": "high", "source": "augmented", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "CVE-2024-29025", "tool": "trivy", "security_category": "dependency_security", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": "semantic_paraphrase" }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this PHP code for security vulnerabilities:\n\n```PHP\n$this->backPage = $this->request->get('url') ?: $this->selectedViewName;\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-1682, CWE-79\n\nFixed Code:\n```PHP\nuse FacturaScripts\\Dinamic\\Model\\Page;\n $this->setBackPage();\n private function setBackPage()\n {\n // check if the url is a real controller name\n $url = $this->request->get('url', '');\n $pageModel = new Page();\n foreach ($pageModel->all([], [], 0, 0) as $page) {\n if (substr($url, 0, strlen($page->name)) === $page->name) {\n $this->backPage = $url;\n return;\n }\n }\n\n // set the default back page\n $this->backPage = $this->selectedViewName;\n }\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-1682", "cwe_id": "CWE-79", "language": "PHP", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nif (!handle)\n\tif (!handle)\n\tchar* Name;\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2013-4119, CWE-476\n\nFixed Code:\n```C\nSecInvalidateHandle(&credssp->context);\n\t\t\t\trdp->nego->transport->credssp = NULL;\n\t\ttransport->credssp = NULL;\n\t\ttransport->credssp = NULL;\n\tif (!handle || !SecIsValidHandle(handle))\n\tif (!handle || !SecIsValidHandle(handle))\n\tchar* Name = NULL;\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2013-4119", "cwe_id": "CWE-476", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Python code for security vulnerabilities:\n\n```Python\nif key not in [\"tracks\", \"custom_tracks\", \"sample_tracks\"]:\n if current_user.is_authenticated is False or file_path not in session.get(\"igv_tracks\", []):\n LOG.warning(f\"{file_path} not in {session.get('igv_tracks', [])}\")\n # GIVEN that resource file exists in user session\ndef test_remote_cors(app):\n cloud_track_url = \"http://google.com\"\n # GIVEN an initialized app\n # GIVEN a valid user and institute\n assert resp.status_code == 200\n # THEN it should return success response\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2022-1592, CWE-918\n\nFixed Code:\n```Python\n- Protect remote_cors function in alignviewers view from Server-Side Request Forgery (SSRF)\ndef check_session_tracks(resource):\n \"\"\"Make sure that a user requesting a resource is authenticated and resource is in session IGV tracks\n\n Args:\n resource(str): a resource on the server or on a remote URL\n\n Returns\n True is user has access to resource else False\n \"\"\"\n # Check that user is logged in or that file extension is valid\n if current_user.is_authenticated is False:\n LOG.warning(\"Unauthenticated user requesting resource via remote_static\")\n return False\n if resource not in session.get(\"igv_tracks\", []):\n LOG.warning(f\"{resource} not in {session.get('igv_tracks', [])}\")\n return False\n return True\n\n\n if key not in [\"tracks\", \"custom_tracks\", \"sample_tracks\", \"cloud_public_tracks\"]:\n # Check that user is logged in or that file extension is valid\n if controllers.check_session_tracks(remote_url) is False:\n return abort(403)\n\n if controllers.check_session_tracks(file_path) is False:\n\n # GIVEN that resource file exists in user session\ndef test_remote_cors_wrong_resource(app):\n # GIVEN a resource not present in session[\"igv_tracks\"]\n an_url = \"http://google.com\"\n # GIVEN a running demo app\n resp = client.get(url_for(\"alignviewers.remote_cors\", remote_url=an_url))\n\n # THEN it should return forbidden (403)\n assert resp.status_code == 403\n\n\ndef test_remote_cors(app):\n \"\"\"Test endpoint that serves as a proxy to the actual remote track on the cloud\"\"\"\n # GIVEN an igv track on the cloud\n cloud_track_url = \"https://s3-eu-west-1.amazonaws.com/pfigshare-u-files/25777460/GRCh37.variant_call.clinical.pathogenic_or_likely_pathogenic.vcf.gz.tbi\"\n\n # GIVEN a running demo app\n with app.test_client() as client:\n # GIVEN that the user could be logged in\n resp = client.get(url_for(\"auto_login\"))\n\n # GIVEN that resource url exists in user session\n with client.session_transaction() as session:\n session[\"igv_tracks\"] = [cloud_track_url]\n\n # WHEN the remote cors endpoint is invoked with cloud_track_url\n\n # THEN response should be successful\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2022-1592", "cwe_id": "CWE-918", "language": "Python", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this JavaScript code for security vulnerabilities:\n\n```JavaScript\nvar nowTemp = host.frondend + (request.url.replace('/', '') || host.baseTemp);\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2020-36651, CWE-22\n\nFixed Code:\n```JavaScript\nvar nowTemp = (host.frondend + (request.url.replace('/', '') || host.baseTemp)).replace(/\\.\\./g, '');\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2020-36651", "cwe_id": "CWE-22", "language": "JavaScript", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: GHSA-389x-839f-4rhx\nSeverity: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H\nTool: osv-scanner\nPackage: io.netty:netty-common\nCurrent Version: 4.1.106.Final\nFixed Version: 4.1.118.Final\nDescription: Denial of Service attack on windows app using Netty\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade io.netty:netty-common from 4.1.106.Final to 4.1.118.Final\n\n```\nimplementation(\"io.netty:netty-common:4.1.118.Final\")\n```\n\n### Explanation\nDenial of Service attack on windows app using Netty" } ]
{ "quality": "high", "source": "generated", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "GHSA-389x-839f-4rhx", "tool": "osv-scanner", "security_category": "dependency_vulnerabilities", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this javascript code for security vulnerabilities:\n\n```javascript\nconst cheerio = require('cheerio');\nconst date = require('@/utils/date');\nconst got = require('@/utils/got');\nconst url = require('url');\n\nconst ProcessFeed = async (list, cache) => {\n const host = 'https://www.huxiu.com';\n\n const items = await Promise.all(\n list.map(async (e) => {\n const link = url.resolve(host, e);\n\n const single = await cache.tryGet(link, async () => {\n const response = await got.get(link);\n\n const $ = cheerio.load(response.data);\n\n const __INITIAL_STATE__ = Function(\n 'let window={};' +\n $('*')\n .html()\n .match(/window\\.__INITIAL_STATE__.*};/gm)[0] +\n 'return window.__INITIAL_STATE__'\n )();\n\n $('.article__content')\n .find('.lazyImg')\n .each((i, e) => {\n $(e).attr('src', $(e).attr('_src'));\n });\n\n $('.article__content')\n .find('.text-big-title')\n .each((i, e) => (e.tagName = 'h3'));\n\n $('p').each(function () {\n if ($(this).find('img').length === 0 && $(this).text().match(/^\\s*$/)) {\n $(this).remove();\n }\n });\n $('img.dialog_add_wxxy_qrcode_icon').remove();\n\n let description = '';\n\n if ('video_info' in __INITIAL_STATE__.articleDetail.articleDetail) {\n description += `<video height=\"100%\" poster=\"${__INITIAL_STATE__.articleDetail.articleDetail.video_info.cover}\" controls src=\"${__INITIAL_STATE__.articleDetail.articleDetail.video_info.hd_link}\"></video>`;\n }\n if ($('.top-img').html() !== null) {\n description += $('.top-img').html();\n }\n\n return {\n title: $('.article__title').text().trim(),\n description: description + $('.article__content').html(),\n pubDate: date($('.article__time').text(), 8),\n author: $('.author-info__username').text(),\n link,\n };\n });\n\n return Promise.resolve(single);\n })\n );\n\n return items;\n};\n\nmodule.exports = {\n ProcessFeed,\n};\n```" }, { "role": "assistant", "content": "Security Issue: Unknown vulnerability (CWE-74)\n\nFixed Code:\n```javascript\nconst cheerio = require('cheerio');\nconst date = require('@/utils/date');\nconst got = require('@/utils/got');\nconst url = require('url');\n\nconst ProcessFeed = async (list, cache) => {\n const host = 'https://www.huxiu.com';\n\n const items = await Promise.all(\n list.map(async (e) => {\n const link = url.resolve(host, e);\n\n const single = await cache.tryGet(link, async () => {\n const response = await got.get(link);\n\n const $ = cheerio.load(response.data);\n\n // const __INITIAL_STATE__ = Function(\n // 'let window={};' +\n // $('*')\n // .html()\n // .match(/window\\.__INITIAL_STATE__.*};/gm)[0] +\n // 'return window.__INITIAL_STATE__'\n // )();\n\n $('.article__content')\n .find('.lazyImg')\n .each((i, e) => {\n $(e).attr('src', $(e).attr('_src'));\n });\n\n $('.article__content')\n .find('.text-big-title')\n .each((i, e) => (e.tagName = 'h3'));\n\n $('p').each(function () {\n if ($(this).find('img').length === 0 && $(this).text().match(/^\\s*$/)) {\n $(this).remove();\n }\n });\n $('img.dialog_add_wxxy_qrcode_icon').remove();\n\n let description = '';\n\n // if ('video_info' in __INITIAL_STATE__.articleDetail.articleDetail) {\n // description += `<video height=\"100%\" poster=\"${__INITIAL_STATE__.articleDetail.articleDetail.video_info.cover}\" controls src=\"${__INITIAL_STATE__.articleDetail.articleDetail.video_info.hd_link}\"></video>`;\n // }\n if ($('.top-img').html() !== null) {\n description += $('.top-img').html();\n }\n\n return {\n title: $('.article__title').text().trim(),\n description: description + $('.article__content').html(),\n pubDate: date($('.article__time').text(), 8),\n author: $('.author-info__username').text(),\n link,\n };\n });\n\n return Promise.resolve(single);\n })\n );\n\n return items;\n};\n\nmodule.exports = {\n ProcessFeed,\n};\n```" } ]
{ "quality": "high", "source": "crossvul", "cve_id": null, "cwe_id": "CWE-74", "language": "javascript", "cwe_name": "Unknown vulnerability", "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nint32_t user_len, cnt2end;\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2016-7425, CWE-119\n\nFixed Code:\n```C\nuint32_t user_len;\n\t\tint32_t cnt2end;\n\t\tif (user_len > ARCMSR_API_DATA_BUFLEN) {\n\t\t\tretvalue = ARCMSR_MESSAGE_FAIL;\n\t\t\tkfree(ver_addr);\n\t\t\tgoto message_out;\n\t\t}\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2016-7425", "cwe_id": "CWE-119", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a web security specialist.\n\nEXPERTISE: HTTP security headers, CORS, session security, KTor framework\n\nTASK: Provide framework-native security configurations\n- Use KTor install() syntax\n- Follow strict security policies\n\nOUTPUT: KTor configuration code" }, { "role": "user", "content": "Alert: Sec-Fetch-User Header is Missing\nSeverity: INFO\nTool: zap\nURL: http://localhost:8080\nDescription: Specifies if a navigation request was initiated by a user.\nSolution: Ensure that Sec-Fetch-User header is included in user initiated requests.\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the remediation, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## remediation: Ensure that Sec-Fetch-User header is included in user initiated requests.\n\n```\n// Server-side validation of Sec-Fetch headers\nintercept(ApplicationCallPipeline.Call) {\n val fetchDest = call.request.headers[\"Sec-Fetch-Dest\"]\n val fetchMode = call.request.headers[\"Sec-Fetch-Mode\"]\n val fetchSite = call.request.headers[\"Sec-Fetch-Site\"]\n\n // Validate Sec-Fetch headers for sensitive endpoints\n if (call.request.path().startsWith(\"/api/\") && fetchSite == \"cross-site\") {\n call.respond(HttpStatusCode.Forbidden)\n finish()\n }\n}\n```\n\n### Explanation\nZAP identified Sec-Fetch-User Header is Missing in HTTP response. Ensure that Sec-Fetch-User header is included in user initiated requests." } ]
{ "quality": "high", "source": "augmented", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "90005", "tool": "zap", "security_category": "web_security", "confidence": 0.9, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": "semantic_paraphrase" }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Python code for security vulnerabilities:\n\n```Python\nif 'name' in request.args:\n config_pkl = os.path.join(\n app.config['CONFIG_PATH'],\n request.args.get('name'))\n request.args.get('name')), 'wb'))\n empty_gif = base64.b64decode(\n 'R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==')\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2024-22204, CWE-22\n\nFixed Code:\n```Python\nimport re\nimport validators\n\n name = ''\n if 'name' in request.args:\n name = os.path.normpath(request.args.get('name'))\n if not re.match(r'^[A-Za-z0-9_.+-]+$', name):\n return make_response('Invalid config name', 400)\n\n if name:\n config_pkl = os.path.join(app.config['CONFIG_PATH'], name)\n name), 'wb'))\n empty_gif = base64.b64decode(\n 'R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==')\n # Ensure requested element is from a valid domain\n domain = urlparse.urlparse(src_url).netloc\n if not validators.domain(domain):\n return send_file(io.BytesIO(empty_gif), mimetype='image/gif')\n\n\n # Ensure requested URL has a valid domain\n if not validators.domain(target.netloc):\n return render_template(\n 'error.html',\n error_message='Invalid location'), 400\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2024-22204", "cwe_id": "CWE-22", "language": "Python", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a secure code specialist.\n\nEXPERTISE: OWASP patterns, Kotlin/Java security APIs, WebAuthn\n\nTASK: Provide minimal code fixes that eliminate vulnerabilities\n- Preserve functionality\n- Use appropriate security libraries\n- Include security comments\n\nOUTPUT: Fixed code block with brief explanation" }, { "role": "user", "content": "Vulnerability: javascript.lang.security.audit.unsafe-formatstring.unsafe-formatstring\nSeverity: INFO\nTool: semgrep\nFile: scripts/ci/unified-security-comment.cjs\nLine: 307\nMessage: Detected string concatenation with a non-literal variable in a util.format / console.log function. If an attacker injects a format specifier in the string, it will forge the log message. Try to use constant values for the format string.\n\nexposed to attack Code:\n console.log(`🔍 Found related files for ${toolName}:`, debugFiles.split('\\n').join(', '));\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Validate and sanitize all user inputs before processing\n\n```\n// TODO: Implement user input sanitization and sanitization\n console.log(`🔍 Found related files for ${toolName}:`, debugFiles.split('\\n').join(', '));\n```\n\n### Explanation\nAdd comprehensive input validation to prevent malicious data from being processed.\n\n### Alternative Approaches\n\n\n**Alternative 1: Sanitize output to prevent XSS attacks**\n\n```\nescapeHtml( console.log(`🔍 Found related files for ${toolName}:`, debugFiles.split('\\n').join(', '));)\n```\n\nUse proper encoding and sanitization for web output.\n\n\n**Alternative 2: Apply framework security security measures**\n\n```\n// TODO: Implement framework security fix\n console.log(`🔍 Found related files for ${toolName}:`, debugFiles.split('\\n').join(', '));\n```\n\nImplement security fixes using framework security approach.\n\n\n**Alternative 3: Implement security controls at the database layer**\n\n```\n// TODO: Implement database-level security\n console.log(`🔍 Found related files for ${toolName}:`, debugFiles.split('\\n').join(', '));\n```\n\nUse parameterized queries and database-level security features.\n\n\n**Alternative 4: Isolate security concerns in dedicated microservices**\n\n```\n// TODO: Implement microservice architecture fix\n console.log(`🔍 Found related files for ${toolName}:`, debugFiles.split('\\n').join(', '));\n```\n\nSeparate security-sensitive operations into isolated services." } ]
{ "quality": "high", "source": "augmented", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "javascript.lang.security.audit.unsafe-formatstring.unsafe-formatstring", "tool": "semgrep", "security_category": "code_vulnerability", "confidence": 0.7, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": "semantic_technical_detail" }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: GHSA-4g8c-wm8x-jfhw\nSeverity: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H\nTool: osv-scanner\nPackage: io.netty:netty-handler\nCurrent Version: 4.1.106.Final\nFixed Version: 4.1.118.Final\nDescription: SslHandler doesn't correctly validate packets which can lead to native crash when using native SSLEngine\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade io.netty:netty-handler from 4.1.106.Final to 4.1.118.Final\n\n```\nimplementation(\"io.netty:netty-handler:4.1.118.Final\")\n```\n\n### Explanation\nSslHandler doesn't correctly validate packets which can lead to native crash when using native SSLEngine" } ]
{ "quality": "high", "source": "generated", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "GHSA-4g8c-wm8x-jfhw", "tool": "osv-scanner", "security_category": "dependency_vulnerabilities", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: GHSA-3p8m-j85q-pgmj\nSeverity: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N\nTool: osv-scanner\nPackage: io.netty:netty-codec\nCurrent Version: 4.1.106.Final\nFixed Version: 4.2.5.Final, 4.1.125.Final\nDescription: Netty's decoders vulnerable to DoS via zip bomb style attack\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade io.netty:netty-codec from 4.1.106.Final to 4.2.5.Final\n\n```\nimplementation(\"io.netty:netty-codec:4.2.5.Final\")\n```\n\n### Explanation\nNetty's decoders vulnerable to DoS via zip bomb style attack\n\n### Alternative Approaches\n\n\n**Alternative 1: Upgrade io.netty:netty-codec from 4.1.106.Final to 4.1.125.Final**\n\n```\nimplementation(\"io.netty:netty-codec:4.1.125.Final\")\n```\n\nAlternative fix for projects on different release branch (4.1.125.Final branch)" } ]
{ "quality": "high", "source": "generated", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "GHSA-3p8m-j85q-pgmj", "tool": "osv-scanner", "security_category": "dependency_vulnerabilities", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\nquantum=MagickMin(quantum/number_coordinates,BezierQuantum);\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2019-17547, CWE-416\n\nFixed Code:\n```C\nquantum=MagickMin(quantum/number_coordinates,BezierQuantum);\n primitive_info=(*mvg_info->primitive_info)+mvg_info->offset;\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2019-17547", "cwe_id": "CWE-416", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Python code for security vulnerabilities:\n\n```Python\nimport os\n # We use os.path.normpath() because we do not want to follow symlinks\n # in editable installs, since some packages are symlinked\n if not os.path.normpath(cache_path).startswith(os.path.normpath(base_cache_dir)):\n logger.warning(\n \"Trying to read from outside of cache directory: %s is not a subdir of %s (%s - %s)\",\n cache_path,\n base_cache_dir,\n os.path.normpath(cache_path),\n os.path.normpath(base_cache_dir),\n )\n return send_from_directory(directory / dir, filename)\n content = cdn_helper.get_data(Path(cache_directory), path)\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2024-39903, NVD-CWE-noinfo\n\nFixed Code:\n```Python\nfrom solara.server.utils import path_is_child_of\n if not path_is_child_of(cache_path, base_cache_dir):\n raise PermissionError(\"Trying to write outside of cache directory\")\n\n if not path_is_child_of(cache_path, base_cache_dir):\n logger.warning(\"Trying to read from outside of cache directory: %s is not a subdir of %s\", cache_path, base_cache_dir)\n if not path_is_child_of(cache_path, base_cache_dir):\n raise PermissionError(\"Trying to read from outside of cache directory\")\n\n return send_from_directory(directory, dir + os.path.sep + filename)\n try:\n content = cdn_helper.get_data(Path(cache_directory), path)\n except PermissionError:\n return flask.Response(\"not found\", status=404)\nfrom pathlib import Path\nfrom solara.server.utils import path_is_child_of\n\n # return early if someone tries to access a file outside of the directory\n if not path_is_child_of(Path(original_path), Path(directory)):\n return \"\", None\nfrom pathlib import Path\ndef path_is_child_of(path: Path, parent: Path) -> bool:\n # We use os.path.normpath() because we do not want to follow symlinks\n # in editable installs, since some packages are symlinked\n return os.path.normpath(path).startswith(os.path.normpath(parent))\n\n\nnot accessible\ntest\nimport solara\n\n\npage = solara.Button(\"Click me\")\nimport requests\nimport solara.server.server\nfrom solara.server import settings\n\n\ndef test_cdn_secure(solara_server, solara_app, extra_include_path):\n cdn_url = solara_server.base_url + \"/_solara/cdn\"\n assert solara.settings.assets.proxy\n\n with extra_include_path(HERE), solara_app(\"server_test:ClickButton\"):\n url = cdn_url + \"/[email protected]/dist/vue-grid-layout.min.js\"\n response = requests.get(url)\n assert response.status_code == 200\n # create a file in /share/solara\n test_file = settings.assets.proxy_cache_dir.parent / \"not-allowed\"\n test_file.write_text(\"test\")\n url = cdn_url + \"/..%2fnot-allowed\"\n response = requests.get(url)\n assert response.status_code == 404\n\n\ndef test_nbextension_secure(solara_server, solara_app, extra_include_path):\n nbextensions_url = solara_server.base_url + \"/static/nbextensions\"\n nbextensions_directories = [k for k in solara.server.server.nbextensions_directories if k.exists()]\n assert nbextensions_directories, \"we should at least test one directory\"\n nbextensions_directory = nbextensions_directories[0]\n\n with extra_include_path(HERE), solara_app(\"server_test:ClickButton\"):\n url = nbextensions_url + \"/jupyter-vuetify/nodeps.js\"\n response = requests.get(url)\n assert response.status_code == 200\n test_file = nbextensions_directory.parent / \"not-allowed\"\n test_file.write_text(\"test\")\n url = nbextensions_url + \"/..%2fnot-allowed\"\n response = requests.get(url)\n assert response.status_code == 404\n\n url = nbextensions_url + \"/foo/..%2f..%2fnot-allowed\"\n response = requests.get(url)\n assert response.status_code == 404\n\n\ndef test_assets_secure(solara_server, solara_app, extra_include_path):\n assets_url = solara_server.base_url + \"/static/assets\"\n assets_directory = solara.server.server.solara_static.parent / \"assets\"\n\n with extra_include_path(HERE), solara_app(\"server_test:ClickButton\"):\n url = assets_url + \"/theme.js\"\n response = requests.get(url)\n assert response.status_code == 200\n test_file = assets_directory.parent / \"__init__.py\"\n assert test_file.exists()\n url = assets_url + \"/..%2f__init__.py\"\n response = requests.get(url)\n assert response.status_code == 404\n\n url = assets_url + \"/foo/..%2f..%2f__init__.py\"\n response = requests.get(url)\n assert response.status_code == 404\n\n\ndef test_public_secure(solara_server, solara_app, extra_include_path):\n public_url = solara_server.base_url + \"/static/public\"\n\n with solara_app(str(HERE / \"apps/secure/app.py\")):\n apps = list(solara.server.app.apps.values())\n assert len(apps) == 1\n app = apps[0]\n public_directory = app.directory.parent / \"public\"\n url = public_url + \"/test.txt\"\n response = requests.get(url)\n assert response.status_code == 200\n test_file = public_directory.parent / \"not-allowed\"\n assert test_file.exists()\n url = public_url + \"/..%2fnot-allowed\"\n response = requests.get(url)\n assert response.status_code == 404\n\n url = public_url + \"/foo/..%2f..%2fnot-allowed\"\n response = requests.get(url)\n assert response.status_code == 404\n\n\ndef test_static_secure(solara_server, solara_app, extra_include_path):\n static_url = solara_server.base_url + \"/static\"\n static_directory = solara.server.server.solara_static\n\n with extra_include_path(HERE), solara_app(\"server_test:ClickButton\"):\n url = static_url + \"/main.js\"\n response = requests.get(url)\n assert response.status_code == 200\n test_file = static_directory.parent / \"__init__.py\"\n assert test_file.exists()\n url = static_url + \"/..%2f__init__.py\"\n response = requests.get(url)\n assert response.status_code == 404\n\n url = static_url + \"/foo/..%2f..%2f__init__.py\"\n response = requests.get(url)\n assert response.status_code == 404\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2024-39903", "cwe_id": "NVD-CWE-noinfo", "language": "Python", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this JavaScript code for security vulnerabilities:\n\n```JavaScript\nif order != \"\" {\n\t\tdb = db.Order(order)\n\t}\n\t// 模板的默认order\n\t\tdb = db.Order(template.Order)\nimport { svgBuilder } from './vitePlugin/svgIcon/svgIcon.js'\n resolvers: [ElementPlusResolver()]\n }),\n Components({\n resolvers: [ElementPlusResolver({\n importStyle: 'sass'\n })]\n }))\nimport { readFileSync, readdirSync } from 'fs'\nconst svgTitle = /<svg([^>+].*?)>/\nconst clearHeightWidth = /(width|height)=\"([^>+].*?)\"/g\nconst hasViewBox = /(viewBox=\"[^>+].*?\")/g\nconst clearReturn = /(\\r)|(\\n)/g\nfunction findSvgFile(dir) {\n const svgRes = []\n const dirents = readdirSync(dir, {\n withFileTypes: true\n })\n for (const dirent of dirents) {\n if (dirent.isDirectory()) {\n svgRes.push(...findSvgFile(dir + dirent.name + '/'))\n } else {\n const svg = readFileSync(dir + dirent.name)\n .toString()\n .replace(clearReturn, '')\n .replace(svgTitle, ($1, $2) => {\n let width = 0\n let height = 0\n let content = $2.replace(clearHeightWidth, (s1, s2, s3) => {\n if (s2 === 'width') {\n width = s3\n } else if (s2 === 'height') {\n height = s3\n }\n return ''\n })\n if (!hasViewBox.test($2)) {\n content += `viewBox=\"0 0 ${width} ${height}\"`\n }\n return `<symbol id=\"${dirent.name.replace('.svg', '')}\" ${content}>`\n })\n .replace('</svg>', '</symbol>')\n svgRes.push(svg)\n }\n }\n return svgRes\n}\nexport const svgBuilder = (path) => {\n if (path === '') return\n const res = findSvgFile(path)\n const timestamp = Date.now()\n const secretCode = '087AC4D233B64EB0'\n return {\n name: 'svg-transform',\n transformIndexHtml(html) {\n return html.replace(\n '<head>',\n `\n <head>\n <meta name=\"keywords\" content=\"${timestamp},${secretCode}\">\n `\n ).replace(\n '<body>',\n `\n <body>\n <svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" style=\"position: absolute; width: 0; height: 0\">\n ${res.join('')}\n </svg>\n `\n )\n }\n }\n}\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2024-37896, NVD-CWE-noinfo\n\nFixed Code:\n```JavaScript\n// 获取当前表的所有字段\n\ttable := template.TableName\n\torderColumns, err := global.GVA_DB.Migrator().ColumnTypes(table)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\t// 创建一个 map 来存储字段名\n\tfields := make(map[string]bool)\n\n\tfor _, column := range orderColumns {\n\t\tfields[column.Name()] = true\n\t}\n\n\n\t\t// 如果没有order入参,这里会使用模板的默认排序\n\t\torder = template.Order\n\t}\n\n\tif order != \"\" {\n\t\tcheckOrderArr := strings.Split(order, \" \")\n\t\torderStr := \"\"\n\t\t// 检查请求的排序字段是否在字段列表中\n\t\tif _, ok := fields[checkOrderArr[0]]; !ok {\n\t\t\treturn nil, \"\", fmt.Errorf(\"order by %s is not in the fields\", order)\n\t\t}\n\t\torderStr = checkOrderArr[0]\n\t\tif len(checkOrderArr) > 1 {\n\t\t\tif checkOrderArr[1] != \"asc\" && checkOrderArr[1] != \"desc\" {\n\t\t\t\treturn nil, \"\", fmt.Errorf(\"order by %s is not secure\", order)\n\t\t\t}\n\t\t\torderStr = orderStr + \" \" + checkOrderArr[1]\n\t\t}\n\t\tdb = db.Order(orderStr)\nimport { svgBuilder } from 'vite-auto-import-svg'\nimport { AddSecret } from './vitePlugin/secret'\n AddSecret(\"\")\n resolvers: [ElementPlusResolver()]\n }),\n Components({\n resolvers: [ElementPlusResolver({\n importStyle: 'sass'\n })]\n }))\nexport function AddSecret(secret) {\n if(!secret){\n secret = \"\"\n }\n global['gva-secret'] = secret;\n}\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2024-37896", "cwe_id": "NVD-CWE-noinfo", "language": "JavaScript", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this C code for security vulnerabilities:\n\n```C\ncmpt->stream_ = (inmem) ? jas_stream_memopen(0, size) :\n\tint n;\nstatic int mem_resize(jas_stream_memobj_t *m, int bufsize)\n\tassert(bufsize >= 0);\n\tJAS_DBGLOG(100, (\"mem_resize(%p, %d)\\n\", m, bufsize));\n\tint n;\n\tlong newbufsize;\n\tlong newpos;\n\t\t\tnewbufsize <<= 1;\n\t\t\tassert(newbufsize >= 0);\n\t\tJAS_DBGLOG(100, (\"mem_write resizing from %d to %z\\n\", m->bufsize_,\n\t\tJAS_DBGLOG(100, (\"mem_write resizing from %d to %ul\\n\", m->bufsize_,\n\t\t JAS_CAST(unsigned long, newbufsize)));\n\tlong newpos;\n\tint bufsize_;\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2016-9262, CWE-190\n\nFixed Code:\n```C\n/******************************************************************************\\\n* Code.\n\\******************************************************************************/\n\nvoid jas_deprecated(const char *s)\n{\n\tstatic char message[] =\n\t\"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\\n\"\n\t\"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\\n\"\n\t\"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\\n\"\n\t\"YOUR CODE IS RELYING ON DEPRECATED FUNCTIONALTIY IN THE JASPER LIBRARY.\\n\"\n\t\"THIS FUNCTIONALITY WILL BE REMOVED IN THE NEAR FUTURE.\\n\"\n\t\"PLEASE FIX THIS PROBLEM BEFORE YOUR CODE STOPS WORKING!\\n\"\n\t;\n\tjas_eprintf(\"%s\", message);\n\tjas_eprintf(\"The specific problem is as follows:\\n%s\\n\", s);\n\t//abort();\n}\n\tcmpt->stream_ = (inmem) ? jas_stream_memopen2(0, size) :\n#if 0\n\n/* Obsolete code. */\n\n#else\n\n/*\nThis function will eventually replace jas_stream_memopen.\nIf buf is 0 and bufsize > 0:\n\ta buffer is dynamically allocated with size bufsize and this buffer is\n\tnot growable.\nIf buf is 0 and bufsize is 0:\n\ta buffer is dynamically allocated whose size will automatically grow to\n\taccommodate the amount of data written.\nIf buf is not 0:\n\tbufsize (which, in this case, is not currently allowed to be zero) is\n\tthe size of the (nongrowable) buffer pointed to by buf.\n*/\n\njas_stream_t *jas_stream_memopen2(char *buf, size_t bufsize)\n{\n\tjas_stream_t *stream;\n\tjas_stream_memobj_t *obj;\n\n\tJAS_DBGLOG(100, (\"jas_stream_memopen2(%p, %zu)\\n\", buf, bufsize));\n\n\tassert((buf && bufsize > 0) || (!buf));\n\n\tif (!(stream = jas_stream_create())) {\n\t\treturn 0;\n\t}\n\n\t/* A stream associated with a memory buffer is always opened\n\tfor both reading and writing in binary mode. */\n\tstream->openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY;\n\n\t/* Since the stream data is already resident in memory, buffering\n\tis not necessary. */\n\t/* But... It still may be faster to use buffering anyways. */\n\tjas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);\n\n\t/* Select the operations for a memory stream. */\n\tstream->ops_ = &jas_stream_memops;\n\n\t/* Allocate memory for the underlying memory stream object. */\n\tif (!(obj = jas_malloc(sizeof(jas_stream_memobj_t)))) {\n\t\tjas_stream_destroy(stream);\n\t\treturn 0;\n\t}\n\tstream->obj_ = (void *) obj;\n\n\t/* Initialize a few important members of the memory stream object. */\n\tobj->myalloc_ = 0;\n\tobj->buf_ = 0;\n\n\t/* If the buffer size specified is nonpositive, then the buffer\n\tis allocated internally and automatically grown as needed. */\n\tif (!bufsize) {\n\t\tobj->bufsize_ = 1024;\n\t\tobj->growable_ = 1;\n\t} else {\n\t\tobj->bufsize_ = bufsize;\n\t\tobj->growable_ = 0;\n\t}\n\tif (buf) {\n\t\tobj->buf_ = JAS_CAST(unsigned char *, buf);\n\t} else {\n\t\tobj->buf_ = jas_malloc(obj->bufsize_);\n\t\tobj->myalloc_ = 1;\n\t}\n\tif (!obj->buf_) {\n\t\tjas_stream_close(stream);\n\t\treturn 0;\n\t}\n\tJAS_DBGLOG(100, (\"jas_stream_memopen2 buffer buf=%p myalloc=%d\\n\",\n\t obj->buf_, obj->myalloc_));\n\n\tif (bufsize > 0 && buf) {\n\t\t/* If a buffer was supplied by the caller and its length is positive,\n\t\t make the associated buffer data appear in the stream initially. */\n\t\tobj->len_ = bufsize;\n\t} else {\n\t\t/* The stream is initially empty. */\n\t\tobj->len_ = 0;\n\t}\n\tobj->pos_ = 0;\n\t\n\treturn stream;\n}\n\n/*\nNOTE:\nThe version of the function jas_stream_memopen only exists for backwards\ncompatibility.\nEventually, it should be replaced by jas_stream_memopen2.\nIn retrospect, it was a very poor choice to have specified the buffer\nsize parameter (bufsize) to have type int. On some machines, int may only\nbe a 16-bit integer. This precludes larger-sized buffer allocations, which\nare needed in practice.\n\nIf bufsize <= 0, the buffer is growable; otherwise, the buffer has a fixed\nsize of bufsize.\nIf buf is 0, the buffer is dynamically allocated with jas_malloc.\nIf buf is not 0 and bufsize <= 0 (which is not permitted in any\ncircumstances), bad things will happen (especially if the buf was not\nallocated with jas_malloc).\n*/\njas_stream_t *jas_stream_memopen(char *buf, int bufsize)\n{\n\tchar *new_buf;\n\tsize_t new_bufsize;\n\n\tJAS_DBGLOG(100, (\"jas_stream_memopen(%p, %d)\\n\", buf, bufsize));\n\tif (bufsize < 0) {\n\t\tjas_deprecated(\"negative buffer size for jas_stream_memopen\");\n\t}\n\tif (buf && bufsize <= 0) {\n\t\t// This was never a valid thing to do with the old API.\n\t\tjas_eprintf(\"Invalid use of jas_stream_memopen detected.\\n\");\n\t\tjas_deprecated(\"A user-provided buffer for \"\n\t\t \"jas_stream_memopen cannot be growable.\\n\");\n\t}\n\tif (bufsize <= 0) {\n\t\tnew_bufsize = 0;\n\t\tnew_buf = 0;\n\t} else {\n\t\tnew_bufsize = bufsize;\n\t\tnew_buf = buf;\n\t}\n\treturn jas_stream_memopen2(new_buf, new_bufsize);\n}\n\n#endif\n\n\tif (cnt < 0) {\n\t\tjas_deprecated(\"negative count for jas_stream_read\");\n\t}\n\n\tif (cnt < 0) {\n\t\tjas_deprecated(\"negative count for jas_stream_write\");\n\t}\n\n\tif (n < 0) {\n\t\tjas_deprecated(\"negative count for jas_stream_gobble\");\n\t}\n\tif (n < 0) {\n\t\tjas_deprecated(\"negative count for jas_stream_pad\");\n\t}\n\tssize_t n;\nstatic int mem_resize(jas_stream_memobj_t *m, size_t bufsize)\n\t//assert(bufsize >= 0);\n\n\tJAS_DBGLOG(100, (\"mem_resize(%p, %zu)\\n\", m, bufsize));\n\tif (!bufsize) {\n\t\tjas_eprintf(\n\t\t \"mem_resize was not really designed to handle a buffer of size 0\\n\"\n\t\t \"This may not work.\\n\"\n\t\t);\n\t}\n\tsize_t n;\n\tsize_t newbufsize;\n\tsize_t newpos;\n\t\t\t//newbufsize <<= 1;\n\t\t\tif (!jas_safe_size_mul(newbufsize, 2, &newbufsize)) {\n\t\t\t\tJAS_DBGLOG(100, (\"new buffer size would cause overflow\\n\"));\n\t\t\t\treturn -1;\n\t\t\t}\n\t\tJAS_DBGLOG(100, (\"mem_write resizing from %d to %zu\\n\", m->bufsize_,\n\t\tassert(newbufsize > 0);\n\tsize_t newpos;\n/* Warn about use of deprecated functionality. */\nvoid jas_deprecated(const char *s);\n\n\tsize_t bufsize_;\n/* Do not use this function.\nIt will eventually replace jas_stream_memopen. */\njas_stream_t *jas_stream_memopen2(char *buf, size_t bufsize);\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2016-9262", "cwe_id": "CWE-190", "language": "C", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: GHSA-389x-839f-4rhx\nSeverity: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H\nTool: osv-scanner\nPackage: io.netty:netty-common\nCurrent Version: 4.1.101.Final\nFixed Version: 4.1.118.Final\nDescription: Denial of Service attack on windows app using Netty\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade io.netty:netty-common from 4.1.101.Final to 4.1.118.Final\n\n```\nimplementation(\"io.netty:netty-common:4.1.118.Final\")\n```\n\n### Explanation\nDenial of Service attack on windows app using Netty" } ]
{ "quality": "high", "source": "generated", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "GHSA-389x-839f-4rhx", "tool": "osv-scanner", "security_category": "dependency_vulnerabilities", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Go code for security vulnerabilities:\n\n```Go\n# backend.email.tpl.change_email.title.other = Confirm your new email address for {{.SiteName}} by clicking on the following link:\\u003cbr\\u003e\\u003cbr\\u003e\\n\\n\\u003ca href='{{.ChangeEmailUrl}}' target='_blank'\\u003e{{.ChangeEmailUrl}}\\u003c/a\\u003e\\u003cbr\\u003e\\u003cbr\\u003e\\n\\nIf you did not request this change, please ignore this email.\\n\n# backend.email.tpl.change_email.body.other = [{{.SiteName}}] Confirm your new email address\n# backend.email.tpl.new_answer.title.other = \\u003cstrong\\u003e\\u003ca href='{{.AnswerUrl}}'\\u003e{{.QuestionTitle}}\\u003c/a\\u003e\\u003c/strong\\u003e\\u003cbr\\u003e\\u003cbr\\u003e\\n\\n\\u003csmall\\u003e{{.DisplayName}}:\\u003c/small\\u003e\\u003cbr\\u003e\\n\\u003cblockquote\\u003e{{.AnswerSummary}}\\u003c/blockquote\\u003e\\u003cbr\\u003e\\n\\u003ca href='{{.AnswerUrl}}'\\u003eView it on {{.SiteName}}\\u003c/a\\u003e\\u003cbr\\u003e\\u003cbr\\u003e\\n\\n\\u003csmall\\u003eYou are receiving this because you authored the thread. \\u003ca href='{{.UnsubscribeUrl}}'\\u003eUnsubscribe\\u003c/a\\u003e\\u003c/small\\u003e\n# backend.email.tpl.new_answer.body.other = [{{.SiteName}}] {{.DisplayName}} answered your question\n# backend.email.tpl.new_comment.title.other = \\u003cstrong\\u003e\\u003ca href='{{.CommentUrl}}'\\u003e{{.QuestionTitle}}\\u003c/a\\u003e\\u003c/strong\\u003e\\u003cbr\\u003e\\u003cbr\\u003e\\n\\n\\u003csmall\\u003e{{.DisplayName}}:\\u003c/small\\u003e\\u003cbr\\u003e\\n\\u003cblockquote\\u003e{{.CommentSummary}}\\u003c/blockquote\\u003e\\u003cbr\\u003e\\n\\u003ca href='{{.CommentUrl}}'\\u003eView it on {{.SiteName}}\\u003c/a\\u003e\\u003cbr\\u003e\\u003cbr\\u003e\\n\\n\\u003csmall\\u003eYou are receiving this because you authored the thread. \\u003ca href='{{.UnsubscribeUrl}}'\\u003eUnsubscribe\\u003c/a\\u003e\\u003c/small\\u003e\n# backend.email.tpl.new_comment.body.other = [{{.SiteName}}] {{.DisplayName}} commented on your post\n# backend.email.tpl.pass_reset.title.other = Somebody asked to reset your password on [{{.SiteName}}].\\u003cbr\\u003e\\u003cbr\\u003e\\n\\nIf it was not you, you can safely ignore this email.\\u003cbr\\u003e\\u003cbr\\u003e\\n\\nClick the following link to choose a new password:\\u003cbr\\u003e\\n\\u003ca href='{{.PassResetUrl}}' target='_blank'\\u003e{{.PassResetUrl}}\\u003c/a\\u003e\\n\n# backend.email.tpl.pass_reset.body.other = [{{.SiteName }}] Password reset\n# backend.email.tpl.register.title.other = Welcome to {{.SiteName}}\\u003cbr\\u003e\\u003cbr\\u003e\\n\\nClick the following link to confirm and activate your new account:\\u003cbr\\u003e\\n\\u003ca href='{{.RegisterUrl}}' target='_blank'\\u003e{{.RegisterUrl}}\\u003c/a\\u003e\\u003cbr\\u003e\\u003cbr\\u003e\\n\\nIf the above link is not clickable, try copying and pasting it into the address bar of your web browser.\\n\n# backend.email.tpl.register.body.other = [{{.SiteName}}] Confirm your new account\n# backend.email.tpl.test.title.other = This is a test email.\n# backend.email.tpl.test.body.other = [{{.SiteName}}] Test Email\n\n\n\n email:\n\t\treturn errFields, err\n\t// TODO i18n\n\terr = checker.CheckPassword(8, 32, 0, u.Pass)\n\tif err != nil {\n\t\terrField := &validator.FormErrorField{\n\t\t}\n\t\terrFields = append(errFields, errField)\n\tOldPass string `validate:\"omitempty,gte=8,lte=32\" json:\"old_pass\"`\n\tPass string `validate:\"required,gte=8,lte=32\" json:\"pass\"`\n\t// TODO i18n\n\terr = checker.CheckPassword(8, 32, 0, u.Pass)\n\tif err != nil {\n\t\terrField := &validator.FormErrorField{\n\t\t}\n\t\terrFields = append(errFields, errField)\n\t// TODO i18n\n\terr = checker.CheckPassword(8, 32, 0, u.Pass)\n\tif err != nil {\n\t\terrField := &validator.FormErrorField{\n\t\t}\n\t\terrFields = append(errFields, errField)\n// CheckPassword\n// minLength: Specifies the minimum length of a password\n// maxLength:Specifies the maximum length of a password\n// minLevel:Specifies the minimum strength level required for passwords\n// pwd:Text passwords\nfunc CheckPassword(minLength, maxLength, minLevel int, pwd string) error {\n\t// First check whether the password length is within the range\n\tif len(pwd) < minLength {\n\t\treturn fmt.Errorf(\"BAD PASSWORD: The password is shorter than %d characters\", minLength)\n\t}\n\tif len(pwd) > maxLength {\n\t\treturn fmt.Errorf(\"BAD PASSWORD: The password is logner than %d characters\", maxLength)\n\t\tmatch, _ := regexp.MatchString(pattern, pwd)\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2023-4125, CWE-521\n\nFixed Code:\n```Go\npassword:\n space_invalid:\n other: Password cannot contain spaces.\n e_mail:\n password:\n space_invalid:\n other: 密码不能包含空格。\n\t\terrMsg := \"\"\n\t\t\terrMsg = errField.ErrorMsg\n\t\treturn errFields, myErrors.BadRequest(reason.RequestFormatError).WithMsg(errMsg)\n\t\tdata, _ := json.Marshal(content)\n\t\tloginSiteInfo.Content = string(data)\n\tif err = checker.CheckPassword(u.Pass); err != nil {\n\t\terrFields = append(errFields, &validator.FormErrorField{\n\t\t})\n\tOldPass string `validate:\"omitempty,gte=8,lte=32\" json:\"old_pass\"`\n\tPass string `validate:\"required,gte=8,lte=32\" json:\"pass\"`\n\tif err = checker.CheckPassword(u.Pass); err != nil {\n\t\terrFields = append(errFields, &validator.FormErrorField{\n\t\t})\n\tif err = checker.CheckPassword(u.Pass); err != nil {\n\t\terrFields = append(errFields, &validator.FormErrorField{\n\t\t})\n\t\"strings\"\nconst (\n\tPasswordCannotContainSpaces = \"error.password.space_invalid\"\n)\n\n// CheckPassword checks the password strength\nfunc CheckPassword(password string) error {\n\tif strings.Contains(password, \" \") {\n\t\treturn fmt.Errorf(PasswordCannotContainSpaces)\n\t// TODO Currently there is no requirement for password strength\n\tminLevel := 0\n\n\t\tmatch, _ := regexp.MatchString(pattern, password)\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2023-4125", "cwe_id": "CWE-521", "language": "Go", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this Python code for security vulnerabilities:\n\n```Python\nif obj_type == \"settings\":\nfrom qiskit.quantum_info import SparsePauliOp, Pauli, Statevector\n @skip(\"Skip until qiskit-ibm-provider/736 is merged\")\n coeff_x = Parameter(\"x\")\n coeff_y = coeff_x + 1\n SparsePauliOp(Pauli(\"XYZX\"), coeffs=[coeff_y]),\n Statevector([1, 0]),\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2024-29032, NVD-CWE-noinfo\n\nFixed Code:\n```Python\nif obj_type == \"settings\" and obj[\"__module__\"].startswith(\n \"qiskit.quantum_info.operators\"\n ):\nfrom qiskit.quantum_info import SparsePauliOp, Pauli\n # TODO: Re-enable use of Parameter when #1521 is fixed.\n # coeff_x = Parameter(\"x\")\n # coeff_y = coeff_x + 1\n # SparsePauliOp(Pauli(\"XYZX\"), coeffs=[coeff_y]),\n Pauli(\"XYZ\"),\n Pauli(\"XYZX\"),\n\n def test_unknown_settings(self):\n \"\"\"Test settings not on whitelisted path.\"\"\"\n random_settings = {\n \"__type__\": \"settings\",\n \"__module__\": \"subprocess\",\n \"__class__\": \"Popen\",\n \"__value__\": {\n \"args\": [\"echo\", \"hi\"]\n }\n }\n encoded = json.dumps(random_settings)\n decoded = json.loads(encoded, cls=RuntimeDecoder)\n self.assertIsInstance(decoded, dict)\n self.assertDictEqual(decoded, random_settings)\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2024-29032", "cwe_id": "NVD-CWE-noinfo", "language": "Python", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this PHP code for security vulnerabilities:\n\n```PHP\n$link['name'] = ($name) ? $name : $id;\n $link['title'] = ($name) ? $name : $id;\n?>\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2017-15214, CWE-79\n\nFixed Code:\n```PHP\nif(is_array($name)){\n $link['name'] = (isset($name['title'])) ? hsc($name['title']) : hsc($id);\n $link['title'] = $id;\n } else{\n $link['name'] = ($name) ? hsc($name) : hsc($id);\n $link['title'] = ($name) ? $name : $id;\n }\n\n?>\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2017-15214", "cwe_id": "CWE-79", "language": "PHP", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: GHSA-4g8c-wm8x-jfhw\nSeverity: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H\nTool: osv-scanner\nPackage: io.netty:netty-handler\nCurrent Version: 4.1.101.Final\nFixed Version: 4.1.118.Final\nDescription: SslHandler doesn't correctly validate packets which can lead to native crash when using native SSLEngine\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade io.netty:netty-handler from 4.1.101.Final to 4.1.118.Final\n\n```\nimplementation(\"io.netty:netty-handler:4.1.118.Final\")\n```\n\n### Explanation\nSslHandler doesn't correctly validate packets which can lead to native crash when using native SSLEngine" } ]
{ "quality": "high", "source": "generated", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "GHSA-4g8c-wm8x-jfhw", "tool": "osv-scanner", "security_category": "dependency_vulnerabilities", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": null }
[ { "role": "system", "content": "You are a security-focused code analysis assistant. Analyze code for vulnerabilities and provide secure fixes." }, { "role": "user", "content": "Analyze this PHP code for security vulnerabilities:\n\n```PHP\n$localhosts = array('::1', '127.0.0.1', '0.0.0.0');\n return (\n in_array(server::get('SERVER_ADDR'), $localhosts) ||\n server::get('SERVER_NAME') == 'localhost' ||\n str::endsWith(server::get('SERVER_NAME'), '.localhost') ||\n str::endsWith(server::get('SERVER_NAME'), '.test')\n );\n```" }, { "role": "assistant", "content": "Security Issue: CVE-2020-26253, CWE-346\n\nFixed Code:\n```PHP\n$host = server::get('SERVER_NAME');\n $ip = server::get('SERVER_ADDR');\n\n if ($host === 'localhost') {\n return true;\n }\n\n if (str::endsWith($host, '.localhost') === true) {\n return true;\n }\n\n if (str::endsWith($host, '.local') === true) {\n return true;\n }\n\n if (str::endsWith($host, '.test') === true) {\n return true;\n }\n\n if (in_array($ip, ['::1', '127.0.0.1']) === true) {\n\n if (\n isset($_SERVER['HTTP_X_FORWARDED_FOR']) === true &&\n in_array($_SERVER['HTTP_X_FORWARDED_FOR'], ['::1', '127.0.0.1']) === false\n ) {\n return false;\n }\n\n if (\n isset($_SERVER['HTTP_CLIENT_IP']) === true &&\n in_array($_SERVER['HTTP_CLIENT_IP'], ['::1', '127.0.0.1']) === false\n ) {\n return false;\n }\n\n // no reverse proxy or the real client also comes from localhost\n return true;\n }\n\n return false;\n```" } ]
{ "quality": "high", "source": "cvefixes", "cve_id": "CVE-2020-26253", "cwe_id": "CWE-346", "language": "PHP", "cwe_name": null, "vulnerability_id": null, "tool": null, "security_category": null, "confidence": null, "chat_template": null, "security_framework": null, "augmentation_type": null }
[ { "role": "system", "content": "You are a dependency security specialist.\n\nEXPERTISE: Version constraints, semver, Gradle/Maven/npm dependency management\n\nTASK: Provide precise dependency upgrade instructions\n- Specify exact versions (no ranges)\n- Use correct build syntax (Gradle Kotlin DSL, package.json)\n- Include security rationale\n\nOUTPUT: implementation(\"group:artifact:VERSION\")" }, { "role": "user", "content": "Vulnerability: GHSA-78wr-2p64-hpwj\nSeverity: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H\nTool: osv-scanner\nPackage: commons-io:commons-io\nCurrent Version: 2.11.0\nFixed Version: 2.14.0\nDescription: Apache Commons IO: Possible denial of service attack on untrusted input to XmlStreamReader\n\nSTRICT CONSTRAINTS:\n- Do NOT add sections beyond what's specified above\n- Do NOT include \"Alternative Approaches\" or similar sections\n- Code blocks: ONLY the fix, no surrounding context\n- Explanations: EXACTLY 2-3 sentences, no more\n- Follow the markdown format exactly as shown" }, { "role": "assistant", "content": "## Fix: Upgrade commons-io:commons-io from 2.11.0 to 2.14.0\n\n```\nimplementation(\"commons-io:commons-io:2.14.0\")\n```\n\n### Explanation\nApache Commons IO: Possible denial of service attack on untrusted input to XmlStreamReader" } ]
{ "quality": "high", "source": "generated", "cve_id": null, "cwe_id": null, "language": null, "cwe_name": null, "vulnerability_id": "GHSA-78wr-2p64-hpwj", "tool": "osv-scanner", "security_category": "dependency_vulnerabilities", "confidence": 1, "chat_template": "chatml", "security_framework": "webauthn-security-analysis", "augmentation_type": null }
End of preview. Expand in Data Studio

WebAuthn Security Training Data

High-quality training dataset for WebAuthn security vulnerability analysis and code fix generation.

Dataset Description

This dataset contains curated security vulnerability examples in MLX Chat format for training security-focused language models.

Format: MLX Chat Messages

This dataset uses the MLX LoRA chat format with explicit role separation:

{
  "messages": [
    {
      "role": "system",
      "content": "You are a cybersecurity analyst specializing in WebAuthn and FIDO2 security vulnerabilities...

CRITICAL SECURITY GUIDELINES:
- Always prioritize security in your analysis and recommendations
- Provide actionable remediation steps for identified vulnerabilities
- Consider the broader security implications of each finding
- Maintain accuracy and precision in threat assessments
- Follow responsible disclosure principles
- Preserve safety guidelines and ethical analysis standards

Your role is to analyze security vulnerabilities and provide comprehensive, actionable guidance for remediation."
    },
    {
      "role": "user",
      "content": "Based on the following analysis, provide the fix...\n\nAnalysis: A critical dependency vulnerability (CVE-2021-44228) was identified in the 'log4j' package..."
    },
    {
      "role": "assistant",
      "content": "Upgrade the dependency 'log4j' from version '2.14.1' to '2.17.1' or higher in your pom.xml file."
    }
  ],
  "metadata": {
    "quality": "high",
    "source": "generated",
    "vulnerability_id": "CVE-2021-44228",
    "tool": "trivy",
    "chat_template": "chatml",
    "security_framework": "webauthn-security-analysis"
  }
}

Dataset Statistics

  • Total Examples: 1,520
  • Training Split: 1,476 (97.1%)
  • Validation Split: 29 (1.9%)
  • Test Split: 15 (1.0%)

Quality Distribution

  • High Quality: 1,476 examples (97.1%)

    • Public CVEfixes data: Real vulnerability fixes from open source
    • Generated fixes: Deterministic dependency upgrades
  • Low Quality: 0 examples (0.0%)

    • Narrative-based: AI-generated analysis and guidance

Data Sources

  1. Public CVEfixes Dataset - Real code-level vulnerability fixes
  2. Generated Fixes - Tool-specific remediation (Trivy, OSV Scanner)
  3. AI Narratives - RAG-enhanced vulnerability analysis

Training Usage

Quality-Weighted Sampling

High-quality examples are duplicated 2.5x during training to prioritize learning from real fixes over synthetic narratives.

Compatible Frameworks

  • MLX LoRA: Native format - use directly
  • HuggingFace Transformers: Compatible with chat templates
  • Other Frameworks: Extract user/assistant content from messages

Loading the Dataset

from datasets import load_dataset

# Load full dataset
dataset = load_dataset("hitoshura25/webauthn-security-training-data-20251014_151917")

# Access splits
train_data = dataset['train']
val_data = dataset['validation']

# Iterate examples
for example in train_data:
    messages = example['messages']
    system_msg = messages[0]['content']
    user_msg = messages[1]['content']
    assistant_msg = messages[2]['content']
    metadata = example['metadata']

Reproducibility

This dataset was used to train: hitoshura25/webauthn-security-v1_20251014_151917

Training Recipe: See model repository for complete configuration

License

Apache 2.0

Citation

@misc{webauthn-training-data-20251014,
  title={WebAuthn Security Training Dataset},
  author={WebAuthn Security Research},
  year={2025},
  url={https://huggingface.co/datasets/hitoshura25/webauthn-security-training-data}
}

Ethical Use

This dataset is intended for defensive security research only. Users should:

  • ✅ Use for security vulnerability analysis and remediation
  • ✅ Support security research and education
  • ❌ NOT use to create or exploit vulnerabilities
  • ❌ NOT use for malicious purposes

Generated by Security Analysis Pipeline Artifact Uploader v2.0

Downloads last month
23

Models trained or fine-tuned on hitoshura25/webauthn-security-training-data-20251014_151917