File size: 39,145 Bytes
c8d30bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | # tools/cwe_database.py
# MITRE CWE ้ข็ท่ณๆๅบซ โ ThreatHunter ๅฏไฟกไฝ่ญไพๆบ
#
# ไพๆบ๏ผMITRE CWE v4.14๏ผhttps://cwe.mitre.org/๏ผ
# ๆณจๆ๏ผๆญคๆชๆกๅ
งๅฎนไพ่ช MITRE ๅฎๆนๅฎ็พฉ๏ผ้ LLM ็ๆ
# ๆดๆฐๆฅๆ๏ผ2026-04-21
#
# ็จ้๏ผ
# ็ถ Security Guard ๅตๆธฌๅฐ code pattern ๆ๏ผ
# ๅผ็จๆญค่ณๆๅบซๆไพๅฎๆนๅฎ็พฉใNIST ๅด้ๆงใOWASP ๅฐๆใไฟฎๅพฉๅปบ่ญฐ
# ไปฅๅไปฃ่กจๆง CVE๏ผๅ้กๅผฑ้ป็ๅฏฆ่ขซๅฉ็จๆกไพ๏ผใ
#
# ้่ฆๅ
่ฒฌ่ฒๆ๏ผ
# ไปฃ่กจๆง CVE ไธไปฃ่กจ็จๆถ็็จๅผ็ขผใๅฐฑๆฏใ่ฉฒ CVE๏ผ
# ่ๆฏใๅ้กๅผฑ้ป่ขซๅฉ็จ็็ๅฏฆๆกไพใ๏ผ็จๆผ่ชชๆ้ขจ้ชๅด้ๆงใ
from __future__ import annotations
import logging
from typing import Any
logger = logging.getLogger("ThreatHunter.cwe_database")
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# MITRE CWE ่ณๆๅบซ
# ๆฌไฝ่ชชๆ๏ผ
# name : CWE ็ญๅ็จฑ
# full_name : MITRE ๅฎๆนๅฎๆดๅ็จฑ
# source : ่ณๆไพๆบ็ๆฌ
# nist_severity : NIST ่ฉๅฎๅด้็ญ็ด
# cvss_base : ๅ
ธๅ CVSS v3.1 ๅบ็คๅๆธ๏ผไพ่ช NVD ็ตฑ่จ๏ผ
# owasp_2021 : OWASP Top 10 2021 ๅฐๆ
# cwe_url : MITRE ๅฎๆน URL
# description : ๅฎๆนๅฎ็พฉๆ่ฆ๏ผ่ฑๆ๏ผMITRE ๅๆ๏ผ
# remediation_en : ่ฑๆไฟฎๅพฉๅปบ่ญฐ
# remediation_zh : ไธญๆไฟฎๅพฉๅปบ่ญฐ
# representative_cves : ไปฃ่กจๆง CVE๏ผ็ๅฏฆๆกไพ๏ผ้็จๆถ็จๅผ็ขผ็็ดๆฅๆ ๅฐ๏ผ
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
CWE_DATABASE: dict[str, dict[str, Any]] = {
# โโ ๆณจๅ
ฅ้ก (Injection) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"CWE-89": {
"name": "SQL Injection",
"full_name": "Improper Neutralization of Special Elements used in an SQL Command",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 8.1,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/89.html",
"description": (
"Without sufficient removal or quoting of SQL syntax in user-controllable inputs, "
"the generated SQL query can cause those inputs to be interpreted as SQL instead of "
"ordinary user data. This can be used to alter query logic to bypass authentication, "
"retrieve, modify, or delete data."
),
"remediation_en": "Use parameterized queries (prepared statements). Never concatenate user input into SQL strings.",
"remediation_zh": "ไฝฟ็จๅๆธๅๆฅ่ฉข๏ผPrepared Statements๏ผใ็ตไธๅฐ็จๆถ่ผธๅ
ฅ็ดๆฅๆผๆฅ้ฒ SQL ๅญไธฒใ",
"representative_cves": [
{"id": "CVE-2023-23752", "cvss": 7.5, "vendor": "Joomla", "year": 2023,
"note": "Improper access checks allow SQL injection via URL parameter"},
{"id": "CVE-2022-21661", "cvss": 7.5, "vendor": "WordPress", "year": 2022,
"note": "SQL injection via WP_Query in core component"},
{"id": "CVE-2023-40028", "cvss": 8.8, "vendor": "Ghost CMS", "year": 2023,
"note": "SQL injection leading to data exposure"},
],
},
"CWE-78": {
"name": "OS Command Injection",
"full_name": "Improper Neutralization of Special Elements used in an OS Command",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/78.html",
"description": (
"The product constructs all or part of an OS command using externally-influenced input "
"but does not neutralize elements that can modify the intended OS command, allowing "
"attackers to execute arbitrary commands with the privileges of the vulnerable process."
),
"remediation_en": "Avoid shell execution functions. Use language APIs that accept argument arrays (not strings).",
"remediation_zh": "้ฟๅ
ไฝฟ็จ shell ๅท่กๅฝๅผใๆน็จ่ช่จ API ไธฆไปฅ้ฃๅๆนๅผๅณ้ๅๆธ๏ผไธไฝฟ็จๅญไธฒๆผๆฅ๏ผใ",
"representative_cves": [
{"id": "CVE-2021-44228", "cvss": 10.0, "vendor": "Apache Log4j", "year": 2021,
"note": "JNDI injection leading to Remote Code Execution (Log4Shell)"},
{"id": "CVE-2022-33891", "cvss": 8.8, "vendor": "Apache Spark", "year": 2022,
"note": "Shell injection via HTTP query parameter"},
{"id": "CVE-2023-44487", "cvss": 7.5, "vendor": "Multiple HTTP servers", "year": 2023,
"note": "HTTP/2 Rapid Reset Attack enabling code execution"},
],
},
"CWE-77": {
"name": "Command Injection",
"full_name": "Improper Neutralization of Special Elements used in a Command",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/77.html",
"description": "The product constructs a command using externally-influenced input without proper neutralization.",
"remediation_en": "Validate and whitelist all input. Use safe APIs instead of direct command execution.",
"remediation_zh": "้ฉ่ญไธฆ็ฝๅๅฎๅๆๆ่ผธๅ
ฅใไฝฟ็จๅฎๅ
จ API ๆฟไปฃ็ดๆฅๅฝไปคๅท่กใ",
"representative_cves": [
{"id": "CVE-2021-44228", "cvss": 10.0, "vendor": "Apache Log4j", "year": 2021,
"note": "Command injection via JNDI lookup"},
],
},
"CWE-79": {
"name": "Cross-Site Scripting (XSS)",
"full_name": "Improper Neutralization of Input During Web Page Generation",
"source": "MITRE CWE v4.14",
"nist_severity": "MEDIUM",
"cvss_base": 6.1,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/79.html",
"description": (
"The product does not neutralize or incorrectly neutralizes user-controllable input "
"before it is placed in output that is used as a web page that is served to other users."
),
"remediation_en": "Encode all output. Use Content Security Policy (CSP). Use framework's built-in escaping.",
"remediation_zh": "ๅฐๆๆ่ผธๅบ้ฒ่ก HTML ็ทจ็ขผใๅ็จ CSPใไฝฟ็จๆกๆถๅ
งๅปบ็ escape ๆฉๅถใ",
"representative_cves": [
{"id": "CVE-2023-32235", "cvss": 6.1, "vendor": "WordPress Plugin", "year": 2023,
"note": "Reflected XSS via unescaped URL parameter"},
{"id": "CVE-2022-40082", "cvss": 5.4, "vendor": "Multiple CMS", "year": 2022,
"note": "Stored XSS via input field"},
],
},
"CWE-80": {
"name": "Basic XSS (Improper HTML Encoding)",
"full_name": "Improper Neutralization of Script-Related HTML Tags in a Web Page",
"source": "MITRE CWE v4.14",
"nist_severity": "MEDIUM",
"cvss_base": 5.4,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/80.html",
"description": "The product does not neutralize or incorrectly neutralizes script tags in user input.",
"remediation_en": "HTML-encode all user output using htmlspecialchars() or equivalent.",
"remediation_zh": "ไฝฟ็จ htmlspecialchars() ๆๅ็ญๅฝๅผๅฐๆๆ็จๆถ่ผธๅบ้ฒ่ก HTML ็ทจ็ขผใ",
"representative_cves": [
{"id": "CVE-2023-32235", "cvss": 6.1, "vendor": "WordPress Plugin", "year": 2023,
"note": "Script injection via unencoded output"},
],
},
"CWE-94": {
"name": "Code Injection",
"full_name": "Improper Control of Generation of Code",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/94.html",
"description": "User input is interpreted as executable code by the application.",
"remediation_en": "Never use eval() or equivalent with user input. Use safe alternatives (JSON.parse, predefined mappings).",
"remediation_zh": "็ตไธๅฐ็จๆถ่ผธๅ
ฅไฝฟ็จ eval()ใไฝฟ็จๅฎๅ
จๆฟไปฃ๏ผJSON.parseใ้ ๅฎ็พฉๆ ๅฐ๏ผใ",
"representative_cves": [
{"id": "CVE-2021-41773", "cvss": 7.5, "vendor": "Apache HTTP Server", "year": 2021,
"note": "Path traversal + code injection in CGI"},
],
},
"CWE-95": {
"name": "Dynamic Code Evaluation (eval Injection)",
"full_name": "Improper Neutralization of Directives in Dynamically Evaluated Code",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/95.html",
"description": (
"The software receives input from an upstream component, but it does not neutralize "
"codes in the input before using it as part of a dynamically-evaluated code."
),
"remediation_en": "Remove all uses of eval() with dynamic input. Use JSON.parse() for data, or a switch/map for logic.",
"remediation_zh": "็งป้คๆๆๅฐๅๆ
่ผธๅ
ฅ็ eval() ไฝฟ็จใ่ณๆๆน็จ JSON.parse()๏ผ้่ผฏๆน็จ switch/mapใ",
"representative_cves": [
{"id": "CVE-2023-29017", "cvss": 10.0, "vendor": "vm2 (Node.js sandbox)", "year": 2023,
"note": "Sandbox escape via eval injection leading to RCE"},
{"id": "CVE-2021-22911", "cvss": 9.8, "vendor": "Rocket.Chat", "year": 2021,
"note": "Server-side eval injection leading to RCE"},
],
},
"CWE-98": {
"name": "PHP File Inclusion",
"full_name": "Improper Control of Filename for Include/Require Statement in PHP",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 8.8,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/98.html",
"description": (
"The PHP application receives input from an upstream component, but does not restrict "
"or incorrectly restricts the input before its use in a require, include, or similar "
"statement, allowing the web server to include and execute unintended PHP files."
),
"remediation_en": "Use a strict whitelist of allowed filenames. Never use user input directly in include/require.",
"remediation_zh": "ไฝฟ็จๅดๆ ผ็ฝๅๅฎ้ๅถๅ
่จฑ็ๆชๆกๅ็จฑใ็ตไธๅฐ็จๆถ่ผธๅ
ฅ็ดๆฅๅณๅ
ฅ include/requireใ",
"representative_cves": [
{"id": "CVE-2023-23752", "cvss": 7.5, "vendor": "Joomla", "year": 2023,
"note": "Improper access check leading to Local File Inclusion"},
{"id": "CVE-2021-39165", "cvss": 9.8, "vendor": "Cachet", "year": 2021,
"note": "Remote File Inclusion via template engine"},
],
},
"CWE-90": {
"name": "LDAP Injection",
"full_name": "Improper Neutralization of Special Elements used in an LDAP Query",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 7.5,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/90.html",
"description": "User-supplied input is incorporated into LDAP queries without sufficient sanitization.",
"remediation_en": "Escape all special LDAP characters. Use parameterized LDAP queries.",
"remediation_zh": "ๅฐๆๆ็นๆฎ LDAP ๅญๅ
้ฒ่ก่ฝ็พฉใไฝฟ็จๅๆธๅ LDAP ๆฅ่ฉขใ",
"representative_cves": [
{"id": "CVE-2021-40539", "cvss": 9.8, "vendor": "ManageEngine", "year": 2021,
"note": "LDAP injection enabling authentication bypass"},
],
},
"CWE-611": {
"name": "XML External Entity (XXE)",
"full_name": "Improper Restriction of XML External Entity Reference",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 8.6,
"owasp_2021": "A05:2021 โ Security Misconfiguration",
"cwe_url": "https://cwe.mitre.org/data/definitions/611.html",
"description": (
"The software processes an XML document that can contain XML entities with URIs that "
"resolve to documents outside of the intended sphere of control, causing the product "
"to embed incorrect documents into its output."
),
"remediation_en": "Disable external entity processing in XML parser. Use allowlist of allowed entities.",
"remediation_zh": "ๅ็จ XML ่งฃๆๅจ็ๅค้จๅฏฆ้ซ่็ใไฝฟ็จๅ
่จฑ็ๅฏฆ้ซ็ฝๅๅฎใ",
"representative_cves": [
{"id": "CVE-2021-44228", "cvss": 10.0, "vendor": "Apache Log4j", "year": 2021,
"note": "XXE via JNDI lookup in log messages"},
{"id": "CVE-2022-21363", "cvss": 7.0, "vendor": "MySQL Connector/J", "year": 2022,
"note": "XXE in XML data processing"},
],
},
# โโ ่ทฏๅพ่ๆไปถๆไฝ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"CWE-22": {
"name": "Path Traversal",
"full_name": "Improper Limitation of a Pathname to a Restricted Directory",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 7.5,
"owasp_2021": "A01:2021 โ Broken Access Control",
"cwe_url": "https://cwe.mitre.org/data/definitions/22.html",
"description": (
"The software uses external input to construct a pathname that is intended to identify "
"a file or directory located underneath a restricted parent directory, but does not "
"properly neutralize special elements within the pathname that can cause it to resolve "
"to a location outside of that directory."
),
"remediation_en": "Canonicalize paths before validation. Validate against a strict whitelist of allowed paths.",
"remediation_zh": "ๅจ้ฉ่ญๅๆญฃ่ฆๅ่ทฏๅพใไฝฟ็จๅดๆ ผ็ฝๅๅฎ้ฉ่ญๅ
่จฑ็่ทฏๅพใ",
"representative_cves": [
{"id": "CVE-2021-41773", "cvss": 7.5, "vendor": "Apache HTTP Server", "year": 2021,
"note": "Path traversal allowing arbitrary file read"},
{"id": "CVE-2022-22965", "cvss": 9.8, "vendor": "Spring Framework", "year": 2022,
"note": "Spring4Shell: path traversal leading to RCE"},
],
},
"CWE-73": {
"name": "External Control of File Name or Path",
"full_name": "External Control of File Name or Path",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 7.5,
"owasp_2021": "A01:2021 โ Broken Access Control",
"cwe_url": "https://cwe.mitre.org/data/definitions/73.html",
"description": "The software allows user input to control or influence paths used in filesystem operations.",
"remediation_en": "Use a whitelist of allowed filenames. Sanitize directory separator characters.",
"remediation_zh": "ไฝฟ็จๅ
่จฑ็ๆชๆกๅ็จฑ็ฝๅๅฎใ้ๆฟพ็ฎ้ๅ้ๅญๅ
ใ",
"representative_cves": [
{"id": "CVE-2021-41773", "cvss": 7.5, "vendor": "Apache HTTP Server", "year": 2021,
"note": "File path control leading to arbitrary file access"},
],
},
"CWE-134": {
"name": "Uncontrolled Format String",
"full_name": "Use of Externally-Controlled Format String",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 8.1,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/134.html",
"description": "User input is used as a format string in functions like printf, allowing memory read/write.",
"remediation_en": "Always use a literal format string. Never pass user input directly as the format argument.",
"remediation_zh": "ๆฐธ้ ไฝฟ็จๅญ้ขๆ ผๅผๅญไธฒใ็ตไธๅฐ็จๆถ่ผธๅ
ฅ็ดๆฅไฝ็บๆ ผๅผๅๆธๅณๅ
ฅใ",
"representative_cves": [
{"id": "CVE-2021-3156", "cvss": 7.8, "vendor": "sudo", "year": 2021,
"note": "Heap-based buffer overflow via format string (Baron Samedit)"},
],
},
# โโ ๅๅบๅๅ่็จๅผๅฎๆดๆง โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"CWE-502": {
"name": "Deserialization of Untrusted Data",
"full_name": "Deserialization of Untrusted Data",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A08:2021 โ Software and Data Integrity Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/502.html",
"description": (
"The application deserializes untrusted data without sufficiently verifying that the "
"resulting data will be valid, allowing attackers to control the state or flow of "
"execution, and potentially execute arbitrary code."
),
"remediation_en": "Use safe data formats (JSON). Implement class allowlisting. Sign serialized data.",
"remediation_zh": "ไฝฟ็จๅฎๅ
จ็่ณๆๆ ผๅผ๏ผJSON๏ผใๅฏฆไฝ้กๅฅ็ฝๅๅฎใๅฐๅบๅๅ่ณๆ้ฒ่ก็ฐฝๅใ",
"representative_cves": [
{"id": "CVE-2018-2628", "cvss": 9.8, "vendor": "Oracle WebLogic", "year": 2018,
"note": "Java deserialization RCE via T3 protocol"},
{"id": "CVE-2017-9248", "cvss": 9.8, "vendor": "Telerik UI", "year": 2017,
"note": ".NET deserialization leading to RCE"},
{"id": "CVE-2022-22947", "cvss": 10.0, "vendor": "Spring Cloud Gateway", "year": 2022,
"note": "Code injection via SPEL in actuator endpoint"},
],
},
"CWE-494": {
"name": "Download of Code Without Integrity Check",
"full_name": "Download of Code Without Integrity Check",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 8.1,
"owasp_2021": "A08:2021 โ Software and Data Integrity Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/494.html",
"description": "The product downloads source code or an executable from a remote location without verifying its integrity.",
"remediation_en": "Verify checksums/signatures before execution. Use HTTPS. Pin dependency versions.",
"remediation_zh": "ๅท่กๅ้ฉ่ญๆ ก้ฉๅ/็ฐฝๅใไฝฟ็จ HTTPSใ้ๅฎไพ่ณด็ๆฌใ",
"representative_cves": [
{"id": "CVE-2022-3602", "cvss": 7.5, "vendor": "OpenSSL", "year": 2022,
"note": "Certificate verification bypass enabling MitM"},
],
},
# โโ ๆๆ่ณๆๆด้ฒ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"CWE-312": {
"name": "Cleartext Storage of Sensitive Information",
"full_name": "Cleartext Storage of Sensitive Information",
"source": "MITRE CWE v4.14",
"nist_severity": "MEDIUM",
"cvss_base": 5.5,
"owasp_2021": "A02:2021 โ Cryptographic Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/312.html",
"description": "Sensitive information (passwords, keys, PII) is stored in cleartext.",
"remediation_en": "Encrypt sensitive data at rest. Use hardware security modules for keys.",
"remediation_zh": "ๅ ๅฏ้ๆ
ๆๆ่ณๆใไฝฟ็จ็กฌ้ซๅฎๅ
จๆจก็ต็ฎก็้้ฐใ",
"representative_cves": [
{"id": "CVE-2023-27163", "cvss": 7.5, "vendor": "request-baskets", "year": 2023,
"note": "SSRF exposing internal credentials in cleartext"},
],
},
"CWE-200": {
"name": "Exposure of Sensitive Information",
"full_name": "Exposure of Sensitive Information to an Unauthorized Actor",
"source": "MITRE CWE v4.14",
"nist_severity": "MEDIUM",
"cvss_base": 5.3,
"owasp_2021": "A02:2021 โ Cryptographic Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/200.html",
"description": "The product exposes sensitive information to an actor that is not explicitly authorized to access it.",
"remediation_en": "Apply least-privilege principle. Audit error messages and logs for sensitive data leakage.",
"remediation_zh": "ๆ็จๆๅฐๆฌ้ๅๅใๅฏฉๆ ธ้ฏ่ชค่จๆฏๅๆฅ่ชไธญ็ๆๆ่ณๆๆดฉๆผใ",
"representative_cves": [
{"id": "CVE-2023-23752", "cvss": 7.5, "vendor": "Joomla", "year": 2023,
"note": "Unauthorized information disclosure via REST API"},
],
},
"CWE-798": {
"name": "Use of Hard-coded Credentials",
"full_name": "Use of Hard-coded Credentials",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A07:2021 โ Identification and Authentication Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/798.html",
"description": "The software contains hard-coded credentials such as passwords or cryptographic keys.",
"remediation_en": "Remove all hard-coded credentials. Use environment variables or secret management systems.",
"remediation_zh": "็งป้คๆๆ็กฌ็ทจ็ขผๆ่ญใๆน็จ็ฐๅข่ฎๆธๆๅฏ้ฐ็ฎก็็ณป็ตฑ๏ผVaultใAWS Secrets Manager ็ญ๏ผใ",
"representative_cves": [
{"id": "CVE-2022-29303", "cvss": 9.8, "vendor": "SolarView Compact", "year": 2022,
"note": "Hard-coded credentials enabling backdoor access"},
{"id": "CVE-2021-20090", "cvss": 9.8, "vendor": "Buffalo Router", "year": 2021,
"note": "Hard-coded admin credentials"},
],
},
# โโ ๅ ๅฏๅผฑ้ป โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"CWE-326": {
"name": "Inadequate Encryption Strength",
"full_name": "Inadequate Encryption Strength",
"source": "MITRE CWE v4.14",
"nist_severity": "MEDIUM",
"cvss_base": 5.9,
"owasp_2021": "A02:2021 โ Cryptographic Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/326.html",
"description": "The software stores or transmits sensitive data using an algorithm that is insufficiently strong given current conditions.",
"remediation_en": "Use AES-256 for symmetric encryption. Use RSA-2048+ or ECC P-256+ for asymmetric. Avoid MD5, SHA-1, DES.",
"remediation_zh": "ๅฐ็จฑๅ ๅฏไฝฟ็จ AES-256ใ้ๅฐ็จฑไฝฟ็จ RSA-2048+ ๆ ECC P-256+ใ้ฟๅ
MD5ใSHA-1ใDESใ",
"representative_cves": [
{"id": "CVE-2022-3602", "cvss": 7.5, "vendor": "OpenSSL", "year": 2022,
"note": "Inadequate certificate verification"},
],
},
"CWE-295": {
"name": "Improper Certificate Validation",
"full_name": "Improper Certificate Validation",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 7.4,
"owasp_2021": "A02:2021 โ Cryptographic Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/295.html",
"description": "The software does not validate, or incorrectly validates, a certificate.",
"remediation_en": "Enable full certificate chain validation. Pin certificates for high-value connections.",
"remediation_zh": "ๅ็จๅฎๆด็ๆ่ญ้้ฉ่ญใๅฐ้ซๅนๅผ้ฃ็ทไฝฟ็จๆ่ญ้ๅฎ๏ผCertificate Pinning๏ผใ",
"representative_cves": [
{"id": "CVE-2021-3449", "cvss": 5.9, "vendor": "OpenSSL", "year": 2021,
"note": "NULL pointer dereference during certificate validation"},
],
},
# โโ ๅญๅๆงๅถ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"CWE-862": {
"name": "Missing Authorization",
"full_name": "Missing Authorization",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 8.8,
"owasp_2021": "A01:2021 โ Broken Access Control",
"cwe_url": "https://cwe.mitre.org/data/definitions/862.html",
"description": "The software does not perform an authorization check when an actor attempts to access a resource or perform an action.",
"remediation_en": "Implement authorization checks on every endpoint. Use deny-by-default policy.",
"remediation_zh": "ๅจๆฏๅ็ซฏ้ปๅฏฆไฝๆๆฌๆชขๆฅใไฝฟ็จ้ ่จญๆ็ต็ญ็ฅใ",
"representative_cves": [
{"id": "CVE-2023-23752", "cvss": 7.5, "vendor": "Joomla", "year": 2023,
"note": "Missing authorization allowing data access"},
{"id": "CVE-2022-27096", "cvss": 8.8, "vendor": "Multiple Web Apps", "year": 2022,
"note": "Broken access control leading to privilege escalation"},
],
},
"CWE-287": {
"name": "Improper Authentication",
"full_name": "Improper Authentication",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A07:2021 โ Identification and Authentication Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/287.html",
"description": "When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.",
"remediation_en": "Use strong multi-factor authentication. Validate session tokens properly.",
"remediation_zh": "ไฝฟ็จๅผทๅคๅ ็ด ่ช่ญใๆญฃ็ขบ้ฉ่ญ Session Tokenใ",
"representative_cves": [
{"id": "CVE-2022-35405", "cvss": 9.8, "vendor": "Zoho ManageEngine", "year": 2022,
"note": "Authentication bypass via improper validation"},
],
},
"CWE-306": {
"name": "Missing Authentication for Critical Function",
"full_name": "Missing Authentication for Critical Function",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A07:2021 โ Identification and Authentication Failures",
"cwe_url": "https://cwe.mitre.org/data/definitions/306.html",
"description": "The software does not perform any authentication for functionality that requires a provable user identity.",
"remediation_en": "Require authentication for all sensitive operations. Implement zero-trust model.",
"remediation_zh": "ๆๆๆๆๆไฝ้ฝ่ฆๆฑ่ช่ญใๅฏฆไฝ้ถไฟกไปปๆจกๅใ",
"representative_cves": [
{"id": "CVE-2021-20090", "cvss": 9.8, "vendor": "Buffalo Network Device", "year": 2021,
"note": "Authentication bypass allowing unauthorized access"},
],
},
# โโ ้ๆพ้ๅฎๅ่ SSRF โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"CWE-601": {
"name": "Open Redirect",
"full_name": "URL Redirection to Untrusted Site",
"source": "MITRE CWE v4.14",
"nist_severity": "MEDIUM",
"cvss_base": 6.1,
"owasp_2021": "A01:2021 โ Broken Access Control",
"cwe_url": "https://cwe.mitre.org/data/definitions/601.html",
"description": "The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect.",
"remediation_en": "Use a whitelist of allowed redirect URLs. Avoid using user input in redirect destinations.",
"remediation_zh": "ไฝฟ็จๅ
่จฑ็้ๅฎๅ URL ็ฝๅๅฎใ้ฟๅ
ๅจ้ๅฎๅ็ฎๆจไธญไฝฟ็จ็จๆถ่ผธๅ
ฅใ",
"representative_cves": [
{"id": "CVE-2023-33246", "cvss": 7.5, "vendor": "Apache RocketMQ", "year": 2023,
"note": "Open redirect enabling phishing attacks"},
],
},
"CWE-918": {
"name": "Server-Side Request Forgery (SSRF)",
"full_name": "Server-Side Request Forgery (SSRF)",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 8.6,
"owasp_2021": "A10:2021 โ Server-Side Request Forgery",
"cwe_url": "https://cwe.mitre.org/data/definitions/918.html",
"description": "The server can be induced to make requests to unintended locations, including internal network services.",
"remediation_en": "Validate and whitelist URLs. Block access to internal IP ranges. Disable unnecessary URL schemes.",
"remediation_zh": "้ฉ่ญไธฆ็ฝๅๅฎๅ URLใๅฐ้ๅฐๅ
ง้จ IP ็ฏๅ็ๅญๅใๅ็จไธๅฟ
่ฆ็ URL ๅๅฎใ",
"representative_cves": [
{"id": "CVE-2023-27163", "cvss": 7.5, "vendor": "request-baskets", "year": 2023,
"note": "SSRF allowing internal network access"},
{"id": "CVE-2019-8451", "cvss": 6.8, "vendor": "Jira", "year": 2019,
"note": "SSRF via IconUriServlet endpoint"},
],
},
# โโ ่จๆถ้ซ่่ณๆบๅ้ก โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"CWE-119": {
"name": "Buffer Overflow",
"full_name": "Improper Restriction of Operations within the Bounds of a Memory Buffer",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/119.html",
"description": "The software performs operations on a memory buffer but can read from or write to a memory location outside of its intended bounds.",
"remediation_en": "Use memory-safe languages. Enable stack canaries, ASLR, and NX. Use bounds-checked functions.",
"remediation_zh": "ไฝฟ็จ่จๆถ้ซๅฎๅ
จ่ช่จใๅ็จๆฃง้็ตฒ้ใASLR ๅ NXใไฝฟ็จๆ้็ๆชขๆฅ็ๅฝๅผใ",
"representative_cves": [
{"id": "CVE-2022-3602", "cvss": 7.5, "vendor": "OpenSSL", "year": 2022,
"note": "Buffer overflow in X.509 certificate verification"},
],
},
"CWE-120": {
"name": "Classic Buffer Overflow",
"full_name": "Buffer Copy without Checking Size of Input",
"source": "MITRE CWE v4.14",
"nist_severity": "CRITICAL",
"cvss_base": 9.8,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/120.html",
"description": "The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer.",
"remediation_en": "Use strncpy/strncat with explicit size limits. Prefer C++ std::string or Rust.",
"remediation_zh": "ไฝฟ็จๅธถๅคงๅฐ้ๅถ็ strncpy/strncatใๅชๅ
ไฝฟ็จ C++ std::string ๆ Rustใ",
"representative_cves": [
{"id": "CVE-2021-3156", "cvss": 7.8, "vendor": "sudo", "year": 2021,
"note": "Heap-based buffer overflow (Baron Samedit)"},
],
},
"CWE-416": {
"name": "Use After Free",
"full_name": "Use After Free",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 7.8,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/416.html",
"description": "The software references memory after it has been freed, which may cause it to crash, use unexpected values, or execute code.",
"remediation_en": "Set pointers to NULL after freeing. Use smart pointers in C++. Use memory-safe languages.",
"remediation_zh": "้ๆพๅพๅฐๆๆจ่จญ็บ NULLใๅจ C++ ไธญไฝฟ็จๆบๆ
งๆๆจใๅชๅ
่ๆ
ฎ่จๆถ้ซๅฎๅ
จ่ช่จใ",
"representative_cves": [
{"id": "CVE-2022-0185", "cvss": 8.4, "vendor": "Linux Kernel", "year": 2022,
"note": "Use-after-free in filesystem context leading to privilege escalation"},
],
},
"CWE-400": {
"name": "Uncontrolled Resource Consumption (ReDoS/DoS)",
"full_name": "Uncontrolled Resource Consumption",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 7.5,
"owasp_2021": "A04:2021 โ Insecure Design",
"cwe_url": "https://cwe.mitre.org/data/definitions/400.html",
"description": "The software does not properly control the allocation and maintenance of a limited resource, allowing attackers to cause denial of service via resource exhaustion.",
"remediation_en": "Implement rate limiting. Audit regex for exponential backtracking. Set resource limits.",
"remediation_zh": "ๅฏฆไฝ้็้ๅถใๅฏฉๆ ธๆญฃๅ่กจ้ๅผๆฏๅฆๆๆๆธๅๆบฏใ่จญ็ฝฎ่ณๆบ้ๅถใ",
"representative_cves": [
{"id": "CVE-2023-28155", "cvss": 7.5, "vendor": "Node.js request", "year": 2023,
"note": "ReDoS via specially crafted URL"},
],
},
"CWE-1333": {
"name": "Inefficient Regular Expression Complexity (ReDoS)",
"full_name": "Inefficient Regular Expression Complexity",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 7.5,
"owasp_2021": "A04:2021 โ Insecure Design",
"cwe_url": "https://cwe.mitre.org/data/definitions/1333.html",
"description": "The product uses a regular expression with an inefficient, exponential worst-case computational complexity that consumes excessive CPU cycles.",
"remediation_en": "Audit regex for catastrophic backtracking. Use linear-time regex engines. Enforce timeouts.",
"remediation_zh": "ๅฏฉๆ ธๆญฃๅ่กจ้ๅผ็็ฝ้ฃๆงๅๆบฏๅ้กใไฝฟ็จ็ทๆงๆ้ๆญฃๅๅผๆใๅผทๅถ่จญ็ฝฎ่ถ
ๆใ",
"representative_cves": [
{"id": "CVE-2022-24999", "cvss": 7.5, "vendor": "qs (npm)", "year": 2022,
"note": "ReDoS in query string parsing"},
],
},
"CWE-1321": {
"name": "Prototype Pollution",
"full_name": "Improperly Controlled Modification of Object Prototype Attributes",
"source": "MITRE CWE v4.14",
"nist_severity": "HIGH",
"cvss_base": 8.1,
"owasp_2021": "A03:2021 โ Injection",
"cwe_url": "https://cwe.mitre.org/data/definitions/1321.html",
"description": "Modifying the Object prototype in JavaScript can affect all objects, allowing attackers to inject malicious properties.",
"remediation_en": "Use Object.create(null) for maps. Validate keys. Use hasOwnProperty checks.",
"remediation_zh": "ไฝฟ็จ Object.create(null) ไฝ็บๆ ๅฐใ้ฉ่ญ้ตๅใไฝฟ็จ hasOwnProperty ๆชขๆฅใ",
"representative_cves": [
{"id": "CVE-2022-37601", "cvss": 9.8, "vendor": "loader-utils (npm)", "year": 2022,
"note": "Prototype pollution via webpack loader configuration"},
{"id": "CVE-2021-23337", "cvss": 7.2, "vendor": "lodash", "year": 2021,
"note": "Prototype pollution via merge/zipObjectDeep"},
],
},
}
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# ๆฅ่ฉขๅฝๅผ
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
def get_cwe_info(cwe_id: str) -> dict | None:
"""
ๆฅ่ฉข CWE ๅฎๆน่ณ่จใ
Args:
cwe_id: CWE ่ญๅฅ็ขผ๏ผไพๅฆ "CWE-89"
Returns:
CWE ่ณ่จๅญๅ
ธ๏ผ่ฅๆชๆพๅฐๅๅๅณ None
"""
normalized = cwe_id.strip().upper()
result = CWE_DATABASE.get(normalized)
if result is None:
logger.debug("[CWE_DB] CWE not found in database: %s", normalized)
return result
def format_cwe_for_advisor(cwe_id: str, include_cves: bool = True) -> str:
"""
ๆ ผๅผๅ CWE ่ณ่จ๏ผไพ Advisor ่ผธๅบไฝฟ็จใ
ๆ ผๅผ่จญ่จๅๅ๏ผ
- ๆ็ขบๆจๆณจไพๆบ๏ผ้ LLM ็ๆ๏ผ
- ๅ
ๅซ MITRE ๅฎๆนๅฎ็พฉใNIST ๅด้ๆงใOWASP ๅฐๆ
- ๅฏ้ธ๏ผไปฃ่กจๆง CVE๏ผ้ๅ
่ฒฌ่ฒๆ๏ผ
Args:
cwe_id: CWE ่ญๅฅ็ขผ
include_cves: ๆฏๅฆๅ
ๅซไปฃ่กจๆง CVE
Returns:
ๆ ผๅผๅๅพ็ๅญไธฒ
"""
info = get_cwe_info(cwe_id)
if not info:
return f"[{cwe_id}] No official data found in MITRE CWE v4.14 database"
lines = [
f"[{cwe_id}] {info['name']}",
f"ไพๆบ๏ผ{info.get('source', 'MITRE CWE')} | "
f"NIST ๅด้ๆง๏ผ{info.get('nist_severity', 'N/A')} | "
f"CVSS Base๏ผ{info.get('cvss_base', 'N/A')}",
f"OWASP๏ผ{info.get('owasp_2021', 'N/A')}",
f"ๅฎๆนURL๏ผ{info.get('cwe_url', '')}",
f"ๅฎ็พฉ๏ผ{info.get('description', '')}",
f"ไฟฎๅพฉ๏ผ{info.get('remediation_zh', info.get('remediation_en', 'N/A'))}",
]
if include_cves:
rep_cves = info.get("representative_cves", [])
if rep_cves:
lines.append(
"ไปฃ่กจๆง CVE๏ผๅ้กๅผฑ้ป็ๅฏฆๆกไพ๏ผ้ๆฌ็จๅผ็ขผ็็ดๆฅ CVE๏ผ๏ผ"
)
for cve in rep_cves[:3]: # ๆๅค 3 ๅ
lines.append(
f" โ {cve['id']} | CVSS {cve['cvss']} | "
f"{cve.get('vendor', '')} ({cve.get('year', '')}) | "
f"{cve.get('note', '')}"
)
return "\n".join(lines)
def get_cwe_severity(cwe_id: str) -> str:
"""ๅๅณ CWE ็ NIST ๅด้ๆง็ญ็ด๏ผHIGH/CRITICAL/MEDIUM/LOW๏ผ๏ผๆช็ฅๅๅๅณ UNKNOWN"""
info = get_cwe_info(cwe_id)
return info.get("nist_severity", "UNKNOWN") if info else "UNKNOWN"
def get_representative_cves(cwe_id: str) -> list[dict]:
"""ๅๅณ CWE ็ไปฃ่กจๆง CVE ๅ่กจ๏ผๆๅค 3 ๅ๏ผ๏ผๆช็ฅๅๅๅณ็ฉบๅ่กจ"""
info = get_cwe_info(cwe_id)
return info.get("representative_cves", [])[:3] if info else []
def list_covered_cwes() -> list[str]:
"""ๅๅณ่ณๆๅบซไธญๆๆ่ฆ่็ CWE ID"""
return sorted(CWE_DATABASE.keys())
|