-->

whaust

顯示具有 API 標籤的文章。 顯示所有文章
顯示具有 API 標籤的文章。 顯示所有文章

2020年4月11日 星期六

Purple Teaming in Java API Development


MODULE 1

Topic:  Secure Development LifeCycle And Chain of Security Tools.

Description: This module mainly focuses on the introduction of security terminology and attacking vectors involved in an application. It also provides an overview of application architecture and the role of different tools involved during the entire course. Its content provides an offensive security methodology from a secure development perspective.

Topics Covered:

  • JAVA Spring Boot features and its advantages
  • Developing a Spring Boot-based REST API
  • Enabling session time-out in the REST API
  • Hands-on introduction to ZAP and POSTMAN
  • What is:
    • Insecure Direct Object Reference
    • SQL injection
    • CSRF token
    • Serialization
    • Deserialization
    • Intercepting proxy tool

Module 1 Exercises:

  • Clone the Spring Boot REST API from git repository and configure the cookies with domain, HTTP and Secure flag being set and explore additional Spring Boot security features
  • Use of POSTMAN client tool to trigger a request to API
  • Intercept the HTTP traffic via proxy tool (ZAP)
  • Modify the traffic and analyze the different sets of data (headers, tokens, etc.) being passed
  • Create a report on what security feature is missing in the HTTP traffic analysis of your developed API

MODULE 2

Topic:  Deserialization Issues in JAVA, Testing, and Mitigating

Description: This module focuses on the different annotation features provided by Spring Boot and develop serialization-deserialization functionality in your API. It provides an overview of the issues related to deserialization in JAVA and how to mitigate these flaws in your API development, as well as different techniques to mitigate input validation bypass issue. It also covers creating custom extensions on ZAP.

Topics Covered:  

  • Identifying Issues with deserialization
  • How to exploit deserialization issues
  • How to mitigate and fix deserialization issues
  • Validating input on the server side
  • Introduction to writing custom extensions on ZAP
  • Implementing a passive scanner on ZAP to check the API request-response
  • Using a basic authentication method for the APIs to restrict public access

Module 2 Exercises:

  • Implement a passive scanner on ZAP with the following features:
    • Session cookie without 'HTTP Only' and ‘Secure’ flag in the developed API (from module-1)
    • to test whether CSRF token enabled for POST method or not (DVWA app)

MODULE 3

Topic:  Security Configuration in Spring Boot and Active Scanning using ZAP

Description: This module focuses on implementing the scope-based authorization features of Spring Boot, secure configuration of an API, along with restricting end-points and internal methods. Moreover, it presents blacklisting of potential dangerous commands in your API Introduction to active scanning feature of ZAP tool.

Topics Covered:

  • Spring Security libraries and java-container-security as dependency in POM file
  • Configuring Spring Security
  • Implementing Scope based authorizations and method level checks
  • Introduction to Spring Boot actuator end-points
  • Introduction to CVSS and active scanning of ZAP
  • Implementing an active scanner feature in ZAP with the following features:
    • Trigger a request on an unauthorized end-point and flag the HTTP code in response
    • Tamper HTTP verb in the API request and flag the response
    • Defining CVSS score and priority in case of a successful attack

Module 3 Exercises:

  • Implementing method level authorizations in a REST API
  • Enable relevant actuator end-points securely
  • Implement an active scanner on ZAP with the following features to check permitted actuator end-points

FINAL EXAM

In this final exercise, you would work on the offensive and defensive side of security, attacking your own developed APIs and mitigating the issues found during your attack.

  1. Secure Development of a REST API with the following features:
  • Development of a REST API with the following features
    • authentication via OAuth 2.0 protocol using third party Authentication Server (Facebook, Google, etc.)
    • input validation scenario using regular expression:
  • Implement passive scanner and active scanner script on OWASP ZAP tool to check for the CSRF token bypass vulnerability (API would be provided to you)
    • empty value in CSRF
    • provide CVSS rating to the issues detected
  1. Provide a Final Secure analysis report of your API security testing against the OWASP Top10 attacks using the tools learned in this course.


If any security issues are found during the test, mitigate/fix them and provide a PoC on the fix.

Evaluation would be based on the number of implemented features from the above-mentioned exercise and on the number of vulnerabilities found and mitigated in the report.


Source : https://pentestmag.com/product/purple-teaming-in-java-api-development/

2020年3月12日 星期四

API 安全考量 ( API Security)

近年來API平台不可避免的吸引更多的攻擊者。只要API平台使用資訊技術,就會有惡意攻擊者試圖找到這些漏洞進行攻擊。API安全大致可以分成兩類,第一類是API濫用,第二類是API攻擊。所謂的API濫用指的就是,使用者(或App)可以去呼叫API大量取得資料。而API攻擊就是注入像是SQL Injection的攻擊語法去攻擊API伺服器,藉此取得相關的主機權限。

以 OWASP API Security Top 10 2019 (註一) 的分類來說,常見的 API 風險有三大項,按照發生頻率來排序,依序是「A2:無效認證與授權」(Broken Authentication)、「A1:無效的對象層級授權」(Broken Object Level Authorization)、「A4:缺乏與存取速率的不足」(Lack of Resource and Rate Limiting),及「A10:記錄和監控機制不足」(Insufficient Logging & Monitoring)
* 註一 : https://owasp.org/www-project-api-security/



以下針對這四類弱點進行介紹:

1. 「A2:無效認證與授權」(Broken Authentication): 意指API平台未做好身份認證管理,導致攻擊者可以輕易登入系統,有機會暫時或永久取得使用者 ID,類似預設密碼、弱密碼概念,在未經授權下進入後台服務,擅自修改平台參數、進行不當操作、建立 Botnet 中繼站等。

2. 「A1:無效的對象層級授權」(Broken Object Level Authorization):意指攻擊者利用後臺權限控管的漏洞能輕易轉換權限,初次通過身份驗證後,不需經過再次驗證即可調用其他使用者的資料。擅自修改為 001、002、003…等等用戶編號,佯裝為不同身份,恣意存取各個使用者的機敏資料。有些案例甚至可以做到「垂直提權」取得管理者身分,造成重大危害。

3. 「A4:缺乏與存取速率的不足」(Lack of Resource and Rate Limiting): 意指 API平台對使用者請求的資源數量、請求次數多寡未施加任何限制,可能導致 API 發佈過多封包、變相釀成 DDoS 攻擊,造成服務停擺。

4. 「A10:記錄和監控機制不足」(Insufficient Logging & Monitoring):當API平台遇到攻擊行為的時候,能否偵測並且有效應對,例如,當發現外部有人正在掃描攻擊時,使用者是否可以針對這些攻擊「感知」並且做到「阻擋」。此外使用記錄可以作為行為模式分析之用,以作為持續精進防護原則依據。

## API防禦措施:

1. 以 TLS (Transport Layer Security) 為基礎
* 傳輸層安全性協定 (TLS) 會將流量加密,以確保用戶與正確的伺服器通訊,是 API 的安全性基礎。所有 API 都應該以 TLS 為基礎。
* 隨時更新 TLS:利用像是 Qualisys SSL Labs 的 SSL Server Test 服務測試 TLS 的配置。(註二:https://www.ssllabs.com/ssltest/)
* 利用追蹤工具、資料遮罩和標記化 (tokenization) 等技術。

2. 加強身份驗證機制
* 使用者與應用程式都需要被驗證身份。
* 控制 API 存取權限是有效確保 API 安全的基礎,API平台應該使用 OAuth 對使用者進行身份驗證。

3. API服務上使用速率限制來防止暴力攻擊,並且管理流量
* 使用速率限制防止暴力攻擊,舉例來說:一個攻擊者可能會利用自動化軟體猜測密碼,造成大量連續登入嘗試。API查詢若不受速率限制,則會無限制地允許此攻擊,直到攻擊成功為止。

4. 使用行為模式 (Behavioral Patterns) 和機器學習阻檔意圖不良的機器人程式
* 監控 API 的存取模式與流量的狀況,才能發現可疑的行為。
* 利用使用記錄進行演算法和機器學習以發現意圖不良的機器人程式。
* 留意有些適用於阻止網路或 Web 攻擊的方法可能不適用於 API。

5. 透過弱點掃瞄、滲透測試、原碼檢測,甚至資安流程監控等服務。



## 運用機器學習分析API使用異常:

在營運API平台時,當有使用異常時,要能即時通知管理者,一般需要建立API即時異常檢測系統。該系統將歷史資料進行分析,分析方法運用機器學習(Machine Learning)演算法,進行資料探勘(Data Mining),對歷史資料進行行為塑模」(Behavior Modeling)


在完成行為塑模」後,可以對即時資料進行檢測(Detect Anomalies),針對異常行為發生時,能及時發出告警或是在應用程式中顯示出來。




















駭客專家以駭客的角度,協助分析 使用異常情境,並在塑模階段與檢測特徵中提出建議。



## 營運介面參考




Popular