目录
=============
■其他资料
代码安全_弱点(脆弱性)分析 CWE、漏洞、防御机制_cwe list 中文库-优快云博客
■分析对象code
各个链接
・352
CWE -CWE-352: Cross-Site Request Forgery (CSRF) (4.13)
・693
CWE -CWE-693: Protection Mechanism Failure (4.13)
・16
CWE - CWE-16: Configuration (4.13)
・296
CWE -CWE-296: Improper Following of a Certificate's Chain of Trust (4.13)
・117
CWE -CWE-117: Improper Output Neutralization for Logs (4.13)
・80
CWE -CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (4.13)
・384
CWE -CWE-384: Session Fixation (4.13)
具体分析
■352
Guidelines for Setting Security Headers | Veracode
Description
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
web应用程序不能或不能充分验证提交请求的用户是否有意提供格式良好、有效、一致的请求。
CSRF攻击与防御
受害者
Bob 在银行有一笔存款,
通过对银行的网站发送请求
http://bank.example/withdraw?account=bob&amount=1000000&for=bob2
可以使 Bob 把 1000000 的存款转到 bob2 的账号下。
通常情况下,该请求发送到网站后,服务器会先验证该请求是否来自一个合法的 session,
并且该 session 的用户 Bob 已经成功登陆。
黑客
Mallory 自己在该银行也有账户,他知道上文中的 URL 可以把钱进行转帐操作。
Mallory 可以自己发送一个请求给银行:
http://bank.example/withdraw?account=bob&amount=1000000&for=Mallory。
但是这个请求来自 Mallory 而非 Bob,他不能通过安全认证,因此该请求不会起作用。
这时,Mallory 想到使用 CSRF 的攻击方式,他先自己做一个网站,在网站中放入如下代码:
src=”http://bank.example/withdraw?account=bob&amount=1000000&for=Mallory ”,
并且通过广告等诱使 Bob 来访问他的网站。当 Bob 访问该网站时,
上述 url 就会从 Bob 的浏览器发向银行,
而这个请求会附带 Bob 浏览器中的 cookie 一起发向银行服务器。大多数情况下,
该请求会失败,因为他要求 Bob 的认证信息。
但是,如果 Bob 当时恰巧刚访问他的银行后不久,
他的浏览器与银行网站之间的 session 尚未过期,
浏览器的 cookie 之中含有 Bob 的认证信息。
这时,悲剧发生了,这个 url 请求就会得到响应,
钱将从 Bob 的账号转移到 Mallory 的账号,而 Bob 当时毫不知情。
等以后 Bob 发现账户钱少了,即使他去银行查询日志,
他也只能发现确实有一个来自于他本人的合法请求转移了资金,
没有任何被攻击的痕迹。而 Mallory 则可以拿到钱后逍遥法外。
===
・CSRF跨站点请求伪造(Cross—Site Request Forgery)
===
・cookie・session
客户端与服务器端的认证方式(cookie,token,session)_cookies are no longer stored in files. please use -优快云博客
===
■693
・Veracode関連
Guidelines for Setting Security Headers | Veracode
===
・点击劫持 clickjacking (也被称为UI-覆盖攻击)
web安全之点击劫持(clickjacking)_clickjacked-优快云博客
===
===
X-Frame-Options HTTP 响应头
是用来给浏览器指示允许一个页面可否在 <frame>, </iframe>
或者 <object> 中展现的标记。
网站可以使用此功能,来确保自己网站的内容没有被嵌套到别人的网站中去,
也从而避免了点击劫持 (clickjacking) 的攻击
服务级别的配置(Apache、IIS)
https://www.cnblogs.com/louby/p/10026052.html
===
Description (说明)
The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.
本产品未使用或错误地使用了一种保护机制,该机制可对针对产品的定向攻击提供足够的防御。
Extended Description (扩展描述)
This weakness covers three distinct situations. A "missing" protection mechanism occurs when the application does not define any mechanism against a certain class of attack. An "insufficient" protection mechanism might provide some defenses - for example, against the most common attacks - but it does not protect against everything that is intended. Finally, an "ignored" mechanism occurs when a mechanism is available and in active use within the product, but the developer has not applied it in some code path.
这种弱点包括三种不同的情况。当应用程序没有定义针对某类攻击的任何机制时,就会出现“缺失”保护机制。一个“不充分”的保护机制可能提供一些防御措施——例如,针对最常见的攻击——但它并不能针对所有预期的攻击提供保护。最后,当一个机制可用并且在产品中正在使用,但是开发人员没有在某些代码路径中应用它时,就会出现“忽略”机制
Relationships (关系)
The table(s) below shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore.
下表显示了与此弱点相关的弱点和高级别类别。这些关系被定义为ChildOf、ParentOf、MemberOf,并为可能存在于较高和较低抽象级别的类似项提供了见解。此外,PeerOf和CanAlsoBe等关系被定义为显示用户可能想要探究的类似弱点。
■16
Weaknesses in this category are typically introduced during the configuration of the software.
这一类的弱点通常是在软件配置过程中引入的。
・web安全:x-content-type-options头设置
web安全:x-content-type-options头设置_html 设置 "x-content-type-options-优快云博客
===
・MIME
MIME(Multipurpose Internet Mail Extensions)多用途互联网邮件扩展类型。
是设定某种扩展名的文件用一种应用程序来打开的方式类型,
当该扩展名文件被访问的时候,浏览器会自动使用指定应用程序来打开。
"application/ecmascript"
"application/javascript"
"application/x-javascript"
"text/ecmascript"
"text/javascript"
"text/jscript"
"text/x-javascript"
"text/vbs"
"text/vbscript"
https://www.cnblogs.com/A2008A/archive/2012/06/26/2563613.html
===
・MIME sniffing
https://www.cnblogs.com/yinlili/p/9887945.html
基于IE的MIME sniffing功能的跨站点脚本攻击
・MIME type confusion attacks
MIME 类型混淆攻击
・防止,MIME 类型混淆攻击
http://www.voidcn.com/article/p-fheiyjku-bbm.html
X-Content-Type-Options: nosniff
例如,我们即使给一个html文档指定Content-Type为"text/plain",在IE8-中这个文档依然会被当做html来解析。
利用浏览器的这个特性,攻击者甚至可以让原本应该解析为图片的请求被解析为JavaScript。
通过下面这个响应头可以禁用浏览器的类型猜测行为:
X-Content-Type-Options: nosniff
■296
Description
The software does not follow, or incorrectly follows, the chain of trust for a certificate back to a trusted root certificate, resulting in incorrect trust of any resource that is associated with that certificate.
软件不遵循或错误地遵循证书的信任链返回到受信任的根证书,从而导致对与该证书关联的任何资源的不正确信任。
Extended Description
If a system does not follow the chain of trust of a certificate to a root server, the certificate loses all usefulness as a metric of trust. Essentially, the trust gained from a certificate is derived from a chain of trust -- with a reputable trusted entity at the end of that list. The end user must trust that reputable source, and this reputable source must vouch for the resource in question through the medium of the certificate.
如果系统没有遵循证书到根服务器的信任链,则证书将失去作为信任度量的所有有用性。从本质上讲,从证书中获得的信任来自一个信任链——在这个信任链的末尾有一个信誉良好的受信任实体。最终用户必须信任该信誉良好的来源,并且该信誉良好的来源必须通过证书的媒介为有关资源提供担保。
In some cases, this trust traverses several entities who vouch for one another. The entity trusted by the end user is at one end of this trust chain, while the certificate-wielding resource is at the other end of the chain. If the user receives a certificate at the end of one of these trust chains and then proceeds to check only that the first link in the chain, no real trust has been derived, since the entire chain must be traversed back to a trusted source to verify the certificate.
在某些情况下,这种信任会穿越多个相互担保的实体。最终用户信任的实体位于该信任链的一端,而持有证书的资源位于该链的另一端。如果用户在其中一个信任链的末端收到证书,然后只检查链中的第一个链接,则没有派生出真正的信任,因为必须将整个链遍历回受信任的源以验证证书。
There are several ways in which the chain of trust might be broken, including but not limited to:
- Any certificate in the chain is self-signed, unless it the root.
- Not every intermediate certificate is checked, starting from the original certificate all the way up to the root certificate.
- An intermediate, CA-signed certificate does not have the expected Basic Constraints or other important extensions.
- The root certificate has been compromised or authorized to the wrong party.
有几种可能打破信任链的方式,包括但不限于:
・链中的任何证书都是自签名的,除非是根证书。
・并非所有中间证书都经过检查,从原始证书一直到根证书。
・一个中间的,CA签名的证书没有预期的基本约束或其他重要的扩展。
・根证书已被泄露或授权给错误的一方。
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore.
下表显示了与此弱点相关的弱点和高级别类别。这些关系被定义为ChildOf、ParentOf、MemberOf,并为可能存在于较高和较低抽象级别的类似项提供了见解。此外,PeerOf和CanAlsoBe等关系被定义为显示用户可能想要探究的类似弱点。
■117
・log注入
代码安全_弱点(脆弱性)分析 CWE、漏洞、防御机制_cwe list 中文库-优快云博客
===
Description
The software does not neutralize or incorrectly neutralizes output that is written to logs.
软件不会中和或错误地中和写入日志的输出。
Extended Description
This can allow an attacker to forge log entries or inject malicious content into logs.
这使得攻击者能够伪造日志条目或将恶意内容注入日志中。
Log forging vulnerabilities occur when:
- Data enters an application from an untrusted source.
- The data is written to an application or system log file.
日志伪造漏洞出现在
1.数据从不受信任的源进入应用程序。
2.数据将写入应用程序或系统日志文件
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore.
下表显示了与此弱点相关的弱点和高级别类别。这些关系被定义为ChildOf、ParentOf、MemberOf,并为可能存在于较高和较低抽象级别的类似项提供了见解。此外,PeerOf和CanAlsoBe等关系被定义为显示用户可能想要探究的类似弱点。
■80
・XSS攻击
https://www.cnblogs.com/shawWey/p/8480452.html
===
Description
The software receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.
软件接收来自上游组件的输入,但它不会中和或错误地中和特殊字符,如“<”、“>”和“&”,这些字符在发送到处理网页的下游组件时可能被解释为web脚本元素。
Extended Description
This may allow such characters to be treated as control characters, which are executed client-side in the context of the user's session. Although this can be classified as an injection problem, the more pertinent issue is the improper conversion of such special characters to respective context-appropriate entities before displaying them to the user.
这可能允许将此类字符视为控制字符,在用户会话的上下文中在客户端执行。尽管这可以被归类为注入问题,但更相关的问题是在向用户显示这些特殊字符之前,将它们不当地转换为相应的上下文相关实体。
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore.
下表显示了与此弱点相关的弱点和高级别类别。这些关系被定义为ChildOf、ParentOf、MemberOf,并为可能存在于较高和较低抽象级别的类似项提供了见解。此外,PeerOf和CanAlsoBe等关系被定义为显示用户可能想要探究的类似弱点。
■384
Description
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
在不使任何现有会话标识符失效的情况下,对用户进行身份验证或以其他方式建立新的用户会话,使攻击者有机会窃取经过身份验证的会话。
■331
CWE - CWE-331: Insufficient Entropy (4.13) (mitre.org)
random.nextInt // CWE 331
This code uses the Random.nextInt() function to generate "unique" identifiers for the receipt pages it generates. Because Random.nextInt() is a statistical PRNG, it is easy for an attacker to guess the strings it generates. Although the underlying design of the receipt system is also faulty, it would be more secure if it used a random number generator that did not produce predictable receipt identifiers, such as a cryptographic PRNG.
===
此代码使用Random.nextInt()函数为其生成的收据页面生成“唯一”标识符。因为Random.nextInt()是一个统计PRNG,所以攻击者很容易猜测它生成的字符串。尽管收据系统的基本设计也有缺陷,但如果它使用不产生可预测收据标识符(如加密PRNG)的随机数生成器,则会更安全。
--- // Veracode // random.nextInt // CWE 331
Standard random number generators do not provide a sufficient amonunt of entropy when used for security purposes
Attackers can brute force the output of pseudorandom number generators such as rand
===
当用于安全目的时,标准随机数生成器不能提供足够的熵
攻击者可以强行输出诸如rand之类的伪随机数生成器
===
熵 entropy
==========
■259
Use of Hard-coded Password
CWE - CWE-259: Use of Hard-coded Password (4.13) (mitre.org)
===
■2024-1205追加
CWE-117
The product does not neutralize or incorrectly neutralizes output that is written to logs.
该产品不会中和或错误地中和写入日志的输出。
====
CWE-918
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
web服务器从上游组件接收URL或类似请求,并检索此URL的内容,但它不能充分确保请求被发送到预期的目的地。
XSPA: Cross Site Port Attack
SSRF: Server-Side Request Forgery
====
CWE-311 ( 例:Random Number)
The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.
该产品使用的算法或方案产生的熵不足,留下的模式或值簇比其他模式或值更有可能出现。
====
CWE-566
The product uses a database table that includes records that should not be accessible to an actor, but it executes a SQL statement with a primary key that can be controlled by that actor.
该产品使用一个数据库表,其中包含参与者不应访问的记录,但它使用该参与者可以控制的主键执行SQL语句。
====
CWE-259
The product contains a hard-coded password, which it uses for its own inbound authentication or for outbound communication to external components.
该产品包含一个硬编码密码,用于自身的入站身份验证或与外部组件的出站通信。
==
■Veracode
===========================
使用
登陆之后,
1.进入对应的Project
2. 点击按钮【Start a Scan】
Life Cycle Stage: 选择 【Not Specified】
Launch Date: 选择 【系统发布的 日期 】
Auto-Scan after Pre Scan: 选择 【off】
3.上传要扫描的资源(Jar,EAR)
4.之后,在Simple Mode中有两个选项①②、选择① 需要注意 !!(笔者选错了,只扫描了一个jar)
① Veracode Default
② Previous Selection 【影响:很有可能,只扫描了一个jar,EAR没有被扫描】
===========================
术语
14.DevSecOps (Development 、 Security 和 Operations) 是开发、安全和运营的融合。
15.SAST (Static Application Security Testing)静态应用程序安全测试技术,可以通过查看软件的源代码来识别组件漏洞。
16.DAST (Dynamic Application Security Testing) 动态应用程序安全测试技术,重点关注OS,ミドルウェア,比如Windows,Oracle,Apache。
17.SCA (Software CompostitionAnalysis) 软件成分分析, 重点关注应用程序中的第三方和开源软件组件和库。它解决了人们日益关注的开源漏洞问题,旨在确保软件供应链的安全。
19.policy Evaluation 策略评估 // Veracode
原则
SCA中的OSS,有 high 以上时,应该使用更好版本的OSS jar,来解消 high
(在 Veracode中,可以查看这个jar的其它的 Version的 评价情况)
(存在所有的 OSS jar 的 都含有 high的这种情况)
====
■2024/12/24整理
CWE-89 (SQL Injection)
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. 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.
该产品使用来自上游组件的受外部影响的输入构建SQL命令的全部或部分,但它不会中和或错误地中和在将SQL命令发送到下游组件时可能修改预期SQL命令的特殊元素。如果在用户可控输入中没有充分删除或引用SQL语法,生成的SQL查询可能会导致这些输入被解释为SQL,而不是普通的用户数据。
===
GPT回答问题整理_004_2024/10/30~-优快云博客
===
===
CWE-502 (JSON的jar相关 jackson)
CWE-502: Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.
==
===
==
CWE-184 (不完整黑名单)
CWE-184: Incomplete List of Disallowed Inputs
The product implements a protection mechanism that relies on a list of inputs (or properties of inputs) that are not allowed by policy or otherwise require other action to neutralize before additional processing takes place, but the list is incomplete.
===