這更像是一個一般性問題,但保護注冊程序中使用的 API 的推薦方法是什么?假設有這些公共 API(不需要用戶憑據,只有 API KEY);
- find_person(有關嘗試注冊的人的資料),回傳是否有人已經存在(不需要用戶憑據,也沒有回傳敏感資訊)。
- create_person(有關嘗試注冊的人的資料),將此人創建到系統中(無需用戶憑據)
我們可以擁有擁有短期 JWT 令牌的“匿名”用戶嗎?例如,SPA Web 應用程式或移動應用程式如何安全地獲取“每會話”匿名用戶?驗證碼在這種情況下真的有用嗎?
我們已經在考慮:
- 每個應用程式的 API KEY(不是每個會話)
- 速率限制
- 用于保護 API 的 DDoS 服務
任何幫助將非常感激。
謝謝
uj5u.com熱心網友回復:
短期 JWT 令牌
我們可以擁有擁有短期 JWT 令牌的“匿名”用戶嗎?
是的,您可以并且它建議您甚至為登錄的用戶執行此操作。請參閱 Auth0 博客什么是重繪 令牌以及如何安全地使用它們:
這篇文章將探討 OAuth 2.0 定義的重繪 令牌的概念。我們將了解它們與其他代幣型別的比較,以及它們如何讓我們平衡安全性、可用性和隱私。
使用令牌匿名用戶或登錄用戶的問題是,他們只能識別誰在請求中,沒有什么是做請求。
WHO 和 WHAT 訪問 API 服務器的區別
我寫了一系列關于 API 和移動安全的文章,在文章為什么你的移動應用程式需要 Api 密鑰?你可以詳細閱讀之間的區別誰和什么是訪問您的API服務器,但我會在這里提取它的主要花費:
向 API 服務器發出請求的內容是什么。它真的是您的移動應用程式的真實實體,還是機器人、自動化腳本或攻擊者使用 Postman 之類的工具手動瀏覽您的 API 服務器?
在誰是移動應用,我們可以驗證,授權和以多種方式確定,比如使用OpenID登錄連接或流的oauth2的用戶。
所以,想想誰的用戶(匿名或登錄)您的API服務器將能夠進行認證和授權訪問資料,并想想什么為令代表用戶的這一要求的軟體。
您可能的解決方案
我們已經在考慮:
- 每個應用程式的 API KEY(不是每個會話)
- 速率限制
- 用于保護 API 的 DDoS 服務
這是基本的安全措施,任何API應該實作,但是當它來給吶高度的信心API服務器該請求確實是從他們就會功虧一簣什么,它預計,您的應用程式的真正和篡改版本。
您可以在我的文章6 大移動 API 保護技術 - 它們足夠了嗎?:
在本文中,我們將探討用于保護 API 的最常用技術,包括使用 HTTPS 保護移動應用程式和 API 之間的通信通道的重要性,如何使用 API 密鑰在每個 API 請求上識別移動應用程式,用戶代理、驗證碼和 IP 地址如何用于機器人緩解,以及最終用戶身份驗證對移動安全和 API 安全的重要性。我們將討論這些技術中的每一種,并討論它們如何影響業務風險狀況,即繞過它們的難易程度。
讀者將理解為什么當今常用的移動 API 保護技術非常幼稚,不適合保護數字業務免受 API 濫用的目的。API 濫用是大多數企業意識到的各種形式,因此使用正確的技術來維護收入和品牌聲譽非常重要。
其他可能的解決方案
例如,SPA Web 應用程式或移動應用程式如何安全地獲取“每會話”匿名用戶?
使用 Web 應用程式,只需使用瀏覽器上的開發人員工具,就可以很容易地對它們進行內省并查看 API 請求及其回應。
For mobile apps more work its required but a plethora of open source tools exist to make it easy and in some cases trivial to the point that even non developers can do it, thus making the task of securing an API server very hard, but not impossible.
So, do to the completely different way how the web and mobile devices work the approaches to secure them will differ.
For Web Apps
Are Captchas actually helpful in this scenario?
Captcha gives you a score to tell you a likely who is in the request is a real human. At the best score it cannot guarantee with an high degree of confidence that what is doing the request is indeed what your API server expects, a genuine and untampered version of your web or mobile app.
To learn some useful techniques to help your API backend to try to respond only to requests coming from what you expect, your genuine web app, you can read my answer to the question Secure api data from calls out of the app, especially the section dedicated to Defending the API Server.
For Mobile Apps
It's more of a general question, but What is the recommended way to protect APIs used in SIGN UP processes?
Despite not being specifically for the signup process I recommend you to read this answer I gave to the question How to secure an API REST for mobile app?, especially the sections Hardening and Shielding the Mobile App, Securing the API Server and A Possible Better Solution.
From that answer the better approach that can be employed is by using a Mobile App Attestation solution that will enable the API server to know is receiving only requests from what it expects, a genuine and untampered version of your mobile app.
Do You Want To Go The Extra Mile?
In any response to a security question I always like to reference the excellent work from the OWASP foundation.
For APIS
OWASP API Security Top 10
The OWASP API Security Project seeks to provide value to software developers and security assessors by underscoring the potential risks in insecure APIs, and illustrating how these risks may be mitigated. In order to facilitate this goal, the OWASP API Security Project will create and maintain a Top 10 API Security Risks document, as well as a documentation portal for best practices when creating or assessing APIs.
For Mobile Apps
OWASP Mobile Security Project - Top 10 risks
The OWASP Mobile Security Project is a centralized resource intended to give developers and security teams the resources they need to build and maintain secure mobile applications. Through the project, our goal is to classify mobile security risks and provide developmental controls to reduce their impact or likelihood of exploitation.
OWASP - Mobile Security Testing Guide:
The Mobile Security Testing Guide (MSTG) is a comprehensive manual for mobile app security development, testing and reverse engineering.
For Web Apps
The Web Security Testing Guide:
The OWASP Web Security Testing Guide includes a "best practice" penetration testing framework which users can implement in their own organizations and a "low level" penetration testing guide that describes techniques for testing most common web application and web service security issues.
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/356284.html
