├── README.md ├── README_pt.md └── more_tips.md /README.md: -------------------------------------------------------------------------------- 1 | # 31-days-of-API-Security-Tips 2 | 3 | ### This challenge is Inon Shkedy's 31 days API Security Tips 4 | 5 | #### -API TIP: 1/31- 6 | 7 | *Older APIs versions tend to be more vulnerable and they lack security mechanisms. 8 | Leverage the predictable nature of REST APIs to find old versions. 9 | Saw a call to `api/v3/login`? Check if `api/v1/login` exists as well. It might be more vulnerable.* 10 | 11 | -------------------------------------------------------------------------------------------------------------------------- 12 | 13 | #### -API TIP: 2/31- 14 | 15 | *Never assume there’s only one way to authenticate to an API! 16 | Modern apps have many API endpoints for AuthN: `/api/mobile/login` | `/api/v3/login` | `/api/magic_link`; etc.. 17 | Find and test all of them for AuthN problems.* 18 | 19 | -------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #### -API TIP:3/31- 22 | 23 | *Remember how SQL Injections used to be extremely common 5-10 years ago, and you could break into almost every company? 24 | BOLA (IDOR) is the new epidemic of API security. 25 | As a pentester, if you understand how to exploit it, your glory is guaranteed.* 26 | 27 | > Learn more about BOLA : [https://medium.com/@inonst/a-deep-dive-on-the-most-critical-api-vulnerability-bola-1342224ec3f2](https://medium.com/@inonst/a-deep-dive-on-the-most-critical-api-vulnerability-bola-1342224ec3f2) 28 | -------------------------------------------------------------------------------------------------------------------------- 29 | 30 | #### -API TIP: 4/31- 31 | 32 | Testing a Ruby on Rails App & noticed an HTTP parameter containing a URL? 33 | Developers sometimes use "Kernel#open" function to access URLs == Game Over. 34 | Just send a pipe as the first character and then a shell command (Command Injection by design) 35 | 36 | > Learn more about the open function: [https://apidock.com/ruby/Kernel/open](https://apidock.com/ruby/Kernel/open) 37 | -------------------------------------------------------------------------------------------------------------------------- 38 | 39 | #### -API TIP:5/31- 40 | 41 | *Found SSRF? use it for:* 42 | * Internal port scanning 43 | * Leverage cloud services(like 169.254.169.254) 44 | * Use http://webhook.site to reveal IP Address & HTTP Library 45 | * Download a very large file (Layer 7 DoS) 46 | * Reflective SSRF? disclose local mgmt consoles 47 | 48 | -------------------------------------------------------------------------------------------------------------------------- 49 | 50 | #### -API TIP: 6/31- 51 | 52 | *Mass Assignment is a real thing. 53 | Modern frameworks encourage developers to use MA without understanding the security implications. 54 | During exploitation, don't guess object's properties names, simply find a GET endpoint that returns all of them.* 55 | ![Infographic](https://pbs.twimg.com/media/ENpsW25XYAAjEJE?format=jpg) 56 | 57 | -------------------------------------------------------------------------------------------------------------------------- 58 | 59 | #### - API TIP: 7/31 - 60 | 61 | *A company exposes an API for developers? 62 | This is not the same API which is used by mobile / web application. Always test them separately. 63 | Don't assume they implement the same security mechanisms.* 64 | 65 | -------------------------------------------------------------------------------------------------------------------------- 66 | 67 | #### - API TIP: 8/31 - 68 | 69 | Pentest for REST API? Give it a chance and check if the API supports SOAP also. 70 | Change the content-type to "application/xml", add a simple XML in the request body, and see how the API handles it. 71 | 72 | > Sometimes the authentication is done in a different component that is shared between REST & SOAP APIs == SOAP API may support JWT 73 | 74 | > If the API returns stack trace with a DUMPling, it's probably vulnerable** 75 | 76 | -------------------------------------------------------------------------------------------------------------------------- 77 | 78 | #### - API TIP: 9/31 - 79 | 80 | *Pentest for APIs? Trying to find BOLA (IDOR) vulnerabilities? IDs in the HTTP bodies/headers tend to be more vulnerable than IDs in URLs. Try to focus on them first.* 81 | 82 | -------------------------------------------------------------------------------------------------------------------------- 83 | 84 | #### -API TIP: 10/31- 85 | 86 | *Exploiting BFLA (Broken Function Level Authorization)? 87 | Leverage the predictable nature of REST to find admin API endpoints! 88 | E.g: you saw the following API call `GET /api/v1/users/` 89 | Give it a chance and change to `DELETE / POST to create/delete users.`* 90 | 91 | -------------------------------------------------------------------------------------------------------------------------- 92 | 93 | #### - API TIP: 11/31 - 94 | 95 | *The API uses Authorization header? Forget about CSRF! 96 | If the authentication mechanism doesn't support cookies, the API is protected against CSRF by design.* 97 | 98 | -------------------------------------------------------------------------------------------------------------------------- 99 | 100 | #### -API TIP : 12/31- 101 | 102 | *Testing for BOLA (IDOR)? 103 | Even if the ID is GUID or non-numeric, try to send a numeric value. 104 | For example: `/?user_id=111` instead of `user_id=inon@traceable.ai` 105 | Sometimes the AuthZ mechanism supports both and it's easier the brute force numbers.* 106 | 107 | -------------------------------------------------------------------------------------------------------------------------- 108 | 109 | #### -API TIP: 13/31- 110 | 111 | *Use Mass Assignment to bypass security mechanisms. 112 | E.g., "enter password" mechanism: 113 | - `POST /api/reset_pass` requires old password. 114 | - `PUT /api/update_user` is vulnerable to MA == can be used to update pass without sending the old one (For CSRF)* 115 | 116 | -------------------------------------------------------------------------------------------------------------------------- 117 | 118 | #### - API TIP: 14/31 - 119 | 120 | *Got stuck during an API pentest? Expand your attack surface! Find sub/sibling domains using http://Virustotal.com & http://Censys.io. 121 | Some of these domains might expose the same APIs with different configurations/versions.* 122 | 123 | -------------------------------------------------------------------------------------------------------------------------- 124 | 125 | #### -API TIP:15/31- 126 | 127 | *Static resource==photo,video,.. 128 | Web Servers(IIS, Apache) treat static resources differently when it comes to authorization. 129 | Even if developers implemented decent authorization, there's a good chance you can access static resources of other users.* 130 | 131 | -------------------------------------------------------------------------------------------------------------------------- 132 | 133 | #### -API TIP: 16/31- 134 | 135 | Even if you use another web proxy, always use Burp in the background. 136 | The guys at @PortSwigger 137 | are doing a really good job at helping you manage your pentest. 138 | Use the “tree view” (free version) feature to see all API endpoints you’ve accessed. 139 | 140 | -------------------------------------------------------------------------------------------------------------------------- 141 | 142 | #### -API TIP:17/31- 143 | 144 | *Mobile Certificate Pinning? 145 | Before you start reverse engineering & patching the client app, check for both iOS & Android clients and older versions of them. 146 | There's a decent chance that the pinning isn't enabled in one of them. Save time.* 147 | 148 | -------------------------------------------------------------------------------------------------------------------------- 149 | 150 | #### -API TIP: 18/31- 151 | 152 | *Companies & developers tend to put more resources (including security) into the main APIs. 153 | Always look for the most niche features that nobody uses to find interesting vulnerabilities. 154 | `POST /api/profile/upload_christmas_voice_greeting`* 155 | 156 | -------------------------------------------------------------------------------------------------------------------------- 157 | 158 | #### -API TIP:19/31- 159 | 160 | *Which features do you find tend to be more vulnerable?* 161 | *I'll start:* 162 | * Organization's user management 163 | * Export to CSV/HTML/PDF 164 | * Custom views of dashboards 165 | * Sub user creation&management 166 | * Object sharing (photos, posts,etc) 167 | 168 | -------------------------------------------------------------------------------------------------------------------------- 169 | 170 | #### - API TIP:20/31- 171 | 172 | *Testing AuthN APIs? 173 | If you test in production, there's a good chance that AuthN endpoints have anti brute-force protection. 174 | Anyhow, DevOps engineers tend to disable rate limiting in non-production environments. Don't forget to test them :)* 175 | 176 | 177 | > A good example of this issue: Facebook Breach (Found by @sehacure) [http://www.anandpraka.sh/2016/03/how-i-could-have-hacked-your-facebook.html](http://www.anandpraka.sh/2016/03/how-i-could-have-hacked-your-facebook.html) 178 | -------------------------------------------------------------------------------------------------------------------------- 179 | 180 | #### -API TIP:21/30- 181 | 182 | *Got stuck during an API pentest? Expand the attack surface! 183 | Use http://archive.com, find old versions of the web-app and explore new API endpoints. 184 | Can't use the client? scan the .js files for URLs. Some of them are API endpoints.* 185 | 186 | -------------------------------------------------------------------------------------------------------------------------- 187 | 188 | #### -API TIP:22/31- 189 | 190 | *APIs tend to leak PII by design. 191 | BE engineers return raw JSON objects and rely on FE engineers to filter out sensitive data. 192 | Found a sensitive resource (e.g, `receipt`)? Find all the EPs that return it: `/download_receipt`,`/export_receipt`, etc..* 193 | 194 | > Some of the endpoints might leak excessive data that should not be accessible by the user. 195 | 196 | > This is an example for OWASP Top 10 For APIs - #3 - Excessive Data Exposure 197 | -------------------------------------------------------------------------------------------------------------------------- 198 | 199 | #### -API TIP:23/31- 200 | 201 | *Found a way to download arbitrary files from a web server? 202 | Shift the test from black-box to white-box. 203 | Download the source code of the app (DLL files: use IL-spy; Compiled Java - use Luyten) 204 | Read the code and find new issues!* 205 | 206 | -------------------------------------------------------------------------------------------------------------------------- 207 | 208 | #### -API TIP:24/31- 209 | 210 | *Got stuck during an API pentest? Expand your attack surface! 211 | Remember: developers often disable security mechanisms in non-production environments (qa/staging/etc); 212 | Leverage this fact to bypass AuthZ, AuthN, rate limiting & input validation.* 213 | 214 | -------------------------------------------------------------------------------------------------------------------------- 215 | 216 | #### -API TIP:25/31- 217 | 218 | *Found an "export to PDF" feature? 219 | There's a good chance the developers use an external library to convert HTML --> PDF behind the scenes. 220 | Try to inject HTML elements and cause "Export Injection".* 221 | 222 | > Learn more about Export Injection: [https://medium.com/@inonst/export-injection-2eebc4f17117](https://medium.com/@inonst/export-injection-2eebc4f17117) 223 | -------------------------------------------------------------------------------------------------------------------------- 224 | 225 | #### -API TIP:26/31- 226 | 227 | *Looking for BOLA (IDOR) in APIs? got 401/403 errors? 228 | AuthZ bypass tricks:* 229 | * Wrap ID with an array` {“id”:111}` --> `{“id”:[111]}` 230 | * JSON wrap `{“id”:111}` --> `{“id”:{“id”:111}}` 231 | * Send ID twice `URL?id=&id=` 232 | * Send wildcard `{"user_id":"*"}` 233 | 234 | > In some cases, the AuthZ mechanism expects a plain string (an ID in this case), and if it receives a JSON instead it won't perform the AuthZ checks. Then, when the input goes to the data fetching component, it might be okay with a JSON instead of string(e.g: it flattens the JSON) 235 | -------------------------------------------------------------------------------------------------------------------------- 236 | 237 | #### -API TIP:27/31- 238 | 239 | *BE Servers no longer responsible for protecting against XSS. 240 | APIs don't return HTML, but JSON instead. 241 | If API returns XSS payload? - 242 | E.g: `{"name":"Inon}` 243 | That's fine! The protection always needs to be on the client side* 244 | 245 | -------------------------------------------------------------------------------------------------------------------------- 246 | 247 | #### -API TIP:28/31- 248 | 249 | *Pentest for .NET apps? Found a param containing file path/name? Developers sometimes use "Path.Combine(path_1,path_2)" to create full path. Path.Combine has weird behavior: if param#2 is absolute path, then param#1 is ignored.* 250 | ##### Leverage it to control the path 251 | 252 | > Learn more: [https://www.praetorian.com/blog/pathcombine-security-issues-in-aspnet-applications](https://www.praetorian.com/blog/pathcombine-security-issues-in-aspnet-applications) 253 | -------------------------------------------------------------------------------------------------------------------------- 254 | 255 | #### -API TIP:29/30- 256 | 257 | *APIs expose the underlying implementation of the app. 258 | Pentesters should leverage this fact to better understand users, roles, resources & correlations between them and find cool vulnerabilities & exploits. 259 | Always be curious about the API responses.* 260 | 261 | -------------------------------------------------------------------------------------------------------------------------- 262 | 263 | #### -API TIP:30/31- 264 | 265 | *Got stuck during an API pentest? Expand your attack surface! 266 | If the API has mobile clients, download old versions of the APK file to explore old/legacy functionality and discover new API endpoints.* 267 | 268 | > Remember: companies don’t always implement security mechanisms from day one && DevOps engineers don’t often deprecate old APIs. Leverage these facts to find shadow API endpoints that don’t implement security mechanism (authorization, input filtering & rate limiting) 269 | 270 | > Download old APK versions of android apps: [https://apkpure.com](https://apkpure.com) 271 | -------------------------------------------------------------------------------------------------------------------------- 272 | 273 | #### -API TIP: 31/31- 274 | 275 | *Found a `limit` / `page` param? (e.g: `/api/news?limit=100`) It might be vulnerable to Layer 7 DoS. Try to send a long value (e.g: `limit=999999999`) and see what happens :)* 276 | 277 | -------------------------------------------------------------------------------------------------------------------------- 278 | 279 | ## Source 280 | 281 | #### All of this information is taken from twitter of Inon Shkedy 282 | ##### Links: 283 | * [Inon Shkedy](https://twitter.com/inonshkedy) 284 | * [Traceableai](https://twitter.com/traceableai/) 285 | * [OWASP API PROJECT](https://github.com/OWASP/API-Security) 286 | -------------------------------------------------------------------------------- /README_pt.md: -------------------------------------------------------------------------------- 1 | # 31 dias de dicas de segurança de API 2 | 3 | ### Este desafio são as dicas de segurança da API de 31 dias da Inon Shkedy 4 | 5 | #### -API TIP: 1/31- 6 | 7 | *As versões mais antigas das APIs tendem a ser mais vulneráveis e não possuem mecanismos de segurança. 8 | Aproveite a natureza previsível das APIs REST para encontrar versões antigas. 9 | Veja uma chamada para `api/v3/login` e verifique se `api/v1/login` também existe. Pode ser mais vulnerável.* 10 | 11 | -------------------------------------------------------------------------------------------------------------------------- 12 | 13 | #### -API TIP: 2/31- 14 | 15 | *Nunca assuma que há apenas uma maneira de se autenticar em uma API! 16 | Aplicativos modernos têm muitos endpoints da API para autorização: `/api/mobile/login` | `/api/v3/login` | `/api/magic_link`; etc .. 17 | Encontre e teste todos eles para encontrar problemas de autorização.* 18 | 19 | -------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #### -API TIP:3/31- 22 | 23 | *Lembra quando SQL Injections costumavam ser extremamente comuns 5 a 10 anos atrás, e mesmo assim você poderia invadir quase todas as empresas? 24 | BOLA (IDOR) é a nova epidemia de segurança de API. 25 | Como pentester, se você entender como explorá-lo, o sucesso é garantido.* 26 | 27 | > Saiba mais sobre o BOLA: [https://medium.com/@inonst/a-deep-dive-on-the-most-critical-api-vulnerability-bola-1342224ec3f2](https://medium.com/@inonst/a-deep-dive-on-the-most-critical-api-vulnerability-bola-1342224ec3f2) 28 | -------------------------------------------------------------------------------------------------------------------------- 29 | 30 | #### -API TIP: 4/31- 31 | 32 | Testando um aplicativo Ruby on Rails e achou um parâmetro HTTP que contém uma URL? 33 | Às vezes, os desenvolvedores usam a função "Kernel#open" para acessar URLs == Game Over. 34 | Basta enviar um pipe como o primeiro caractere e depois um comando shell (Command Injection por design) 35 | 36 | > Saiba mais sobre open function: [https://apidock.com/ruby/Kernel/open](https://apidock.com/ruby/Kernel/open) 37 | -------------------------------------------------------------------------------------------------------------------------- 38 | 39 | #### -API TIP:5/31- 40 | 41 | *Achou SSRF (Server-side request forgery) ? Use-o para:* 42 | * Varredura de portas internas 43 | * Aproveite os serviços em nuvem (como 169.254.169.254) 44 | * Use http://webhook.site para revelar o endereço IP e as bibliotecas HTTP 45 | * Faça o download de um arquivo muito grande (camada 7 DoS) 46 | * SSRF reflexivo? descubra os gerenciamentos de consoles locais 47 | 48 | -------------------------------------------------------------------------------------------------------------------------- 49 | 50 | #### -API TIP: 6/31- 51 | 52 | *Mass Assignment é algo real. 53 | Os frameworks modernos incentivam os desenvolvedores a usar o MA sem entender as implicações de segurança. 54 | Durante a exploração, não adivinhe os nomes das propriedades do objeto, basta encontrar um endpoint GET que retorne todos eles.* 55 | 56 | ![Infographic](https://pbs.twimg.com/media/ENpsW25XYAAjEJE?format=jpg) 57 | 58 | -------------------------------------------------------------------------------------------------------------------------- 59 | 60 | #### - API TIP: 7/31 - 61 | 62 | *Uma empresa expõe uma API para desenvolvedores? 63 | Esta não é a mesma API usada pelo aplicativo móvel / web. Sempre teste-os separadamente. 64 | Não pense que eles implementam os mesmos mecanismos de segurança.* 65 | 66 | -------------------------------------------------------------------------------------------------------------------------- 67 | 68 | #### - API TIP: 8/31 - 69 | 70 | Pentest para API REST? Dê uma chance e verifique se a API também suporta SOAP. 71 | Altere o content-type para "application/xml", adicione um XML simples no request body e veja como a API lida com isso. 72 | 73 | > Às vezes, a autenticação é feita em um componente diferente que é compartilhado entre APIs REST e SOAP == API SOAP pode suportar JWT 74 | 75 | > Se a API retornar o stack trace com um DUMPling, provavelmente será vulnerável ** 76 | 77 | -------------------------------------------------------------------------------------------------------------------------- 78 | 79 | #### - API TIP: 9/31 - 80 | 81 | *Pentest para APIs? Tentando encontrar vulnerabilidades do BOLA (IDOR)? 82 | Os IDs nos HTTP bodies/headers tendem a ser mais vulneráveis que os IDs nas URLs. 83 | Tente se concentrar neles primeiro.* 84 | 85 | -------------------------------------------------------------------------------------------------------------------------- 86 | 87 | #### -API TIP: 10/31- 88 | 89 | *Explorando o BFLA (Broken Function Level Authorization)? 90 | Aproveite a natureza previsível do REST para encontrar endpoints da API do administrador! 91 | Por exemplo: você viu a seguinte chamada de API `GET /api/v1/users/` 92 | Dê uma chance e mude para `DELETE / POST para criar / excluir usuários`.* 93 | 94 | -------------------------------------------------------------------------------------------------------------------------- 95 | 96 | #### - API TIP: 11/31 - 97 | 98 | *A API usa o Authorization header? Esqueça o CSRF! 99 | Se o mecanismo de autenticação não suportar cookies, a API será protegida contra CSRF por design.* 100 | 101 | -------------------------------------------------------------------------------------------------------------------------- 102 | 103 | #### -API TIP : 12/31- 104 | 105 | *Teste para BOLA (IDOR)? 106 | Mesmo se o ID for GUID ou não numérico, tente enviar um valor numérico. 107 | Por exemplo: `/?user_id=111` em vez de` user_id=inon@traceable.ai` 108 | Às vezes, o mecanismo de autorização suporta ambos e é mais fácil fazer força bruta com números.* 109 | 110 | -------------------------------------------------------------------------------------------------------------------------- 111 | 112 | #### -API TIP: 13/31- 113 | 114 | *Use Mass Assignment para ignorar os mecanismos de segurança. 115 | Por exemplo, mecanismo "inserir senha": 116 | - `POST /api/rest_pass` requer senha antiga. 117 | - `PUT /api/update_user` é vulnerável ao MA == pode ser usado para atualizar a senha sem enviar a antiga (para CSRF)* 118 | 119 | -------------------------------------------------------------------------------------------------------------------------- 120 | 121 | #### - API TIP: 14/31 - 122 | 123 | *Ficou travado durante um teste de API? Expanda sua superfície de ataque! Encontre subdomínios / irmãos usando http://Virustotal.com e http://Censys.io. 124 | Alguns desses domínios podem expor as mesmas APIs com diferentes configurações / versões.* 125 | 126 | -------------------------------------------------------------------------------------------------------------------------- 127 | 128 | #### -API TIP:15/31- 129 | 130 | *Recursos estáticos == fotos, vídeos, .. 131 | Servidores Web (IIS, Apache) tratam recursos estáticos de maneira diferente quando se trata de autorização. 132 | Mesmo que os desenvolvedores implementem uma autorização decente, há uma boa chance de você acessar recursos estáticos de outros usuários.* 133 | 134 | -------------------------------------------------------------------------------------------------------------------------- 135 | 136 | #### -API TIP: 16/31- 137 | 138 | Mesmo se você usar outro proxy da web, sempre use Burp em segundo plano. 139 | Os caras da @PortSwigger estão fazendo um trabalho muito bom em ajudá-lo a gerenciar o seu pentest. 140 | Use o recurso "tree view" (versão gratuita) para ver todos os endpoints da API que você acessou. 141 | 142 | -------------------------------------------------------------------------------------------------------------------------- 143 | 144 | #### -API TIP:17/31- 145 | 146 | *Mobile Certificate Pinning? 147 | Antes de iniciar a engenharia reversa e aplicar patches no aplicativo cliente, verifique os clientes iOS e Android e versões mais antigas deles. 148 | Há uma boa chance de que o pinning não esteja ativado em um deles. Economize tempo.* 149 | 150 | -------------------------------------------------------------------------------------------------------------------------- 151 | 152 | #### -API TIP: 18/31- 153 | 154 | *Empresas e desenvolvedores tendem a colocar mais recursos (incluindo segurança) nas principais APIs. 155 | Sempre procure os recursos mais específicos que ninguém usa para encontrar vulnerabilidades interessantes. 156 | `POST /api/profile/upload_christmas_voice_greeting`* 157 | 158 | -------------------------------------------------------------------------------------------------------------------------- 159 | 160 | #### -API TIP:19/31- 161 | 162 | *Quais recursos você acha que tendem a ser mais vulneráveis?* 163 | *Vou começar:* 164 | * Gerenciamento de usuários da organização 165 | * Exportar para CSV / HTML / PDF 166 | * Visualizações personalizadas de painéis 167 | * Criação e gerenciamento de usuários 168 | * Compartilhamento de objetos (fotos, postagens, etc) 169 | 170 | -------------------------------------------------------------------------------------------------------------------------- 171 | 172 | #### - API TIP:20/31- 173 | 174 | *Testando APIs de autorização? 175 | Se você testar na produção, há uma boa chance dos endpoints de autorização terem proteção contra força bruta. 176 | De qualquer forma, os engenheiros de DevOps tendem a desativar o rate limit em ambientes que não são de produção. 177 | Não se esqueça de testá-los :)* 178 | 179 | > Um bom exemplo desse problema: falha do Facebook (encontrado por @sehacure) [http://www.anandpraka.sh/2016/03/how-i-could-have-hacked-your-facebook.html](http://www.anandpraka.sh/2016/03/how-i-could-have-hacked-your-facebook.html) 180 | -------------------------------------------------------------------------------------------------------------------------- 181 | 182 | #### -API TIP:21/30- 183 | 184 | *Ficou preso durante um teste de API? Expanda a superfície de ataque! 185 | Use http://archive.com, encontre versões antigas do aplicativo Web e explore novos endpoints da API. 186 | Não pode usar o cliente? Verifique os arquivos .js nas URLs. Alguns deles são endpoints da API. * 187 | 188 | -------------------------------------------------------------------------------------------------------------------------- 189 | 190 | #### -API TIP:22/31- 191 | 192 | *As APIs tendem a vazar PII (Personally Identifiable Information) por design. 193 | Os engenheiros de back-end retornam objetos JSON brutos e confiam nos engenheiros de front-end para filtrar dados confidenciais. 194 | Encontrou um recurso confidencial (por exemplo, `recibo`)? Encontre todos os endpoints que retornam: `/download_receipt`,`/export_receipt`, etc..* 195 | 196 | > Alguns endpoints podem vazar dados excessivos que não devem ser acessíveis pelo usuário. 197 | 198 | > Este é um exemplo dos Top 10 OWASP para APIs - #3 - Exposição excessiva a dados 199 | -------------------------------------------------------------------------------------------------------------------------- 200 | 201 | #### -API TIP:23/31- 202 | 203 | *Encontrou uma maneira de baixar arquivos aleatórios de um servidor web? 204 | Mude o teste de caixa preta para caixa branca. 205 | Baixe o código fonte do aplicativo (arquivos DLL: use IL-spy; Java compilado - use Luyten) 206 | Leia o código e encontre novos problemas!* 207 | 208 | -------------------------------------------------------------------------------------------------------------------------- 209 | 210 | #### -API TIP:24/31- 211 | 212 | *Ficou travado durante um teste de API? Expanda sua superfície de ataque! 213 | Lembre-se: os desenvolvedores geralmente desativam os mecanismos de segurança em ambientes que não são de produção (QA / staging / etc); 214 | Aproveite esse fato para ignorar autorização, rate limit e validação de entrada.* 215 | 216 | -------------------------------------------------------------------------------------------------------------------------- 217 | 218 | #### -API TIP:25/31- 219 | 220 | *Encontrou um recurso "exportar para PDF"? 221 | Há uma boa chance dos desenvolvedores usarem uma biblioteca externa para converter HTML -> PDF no background. 222 | Tente injetar elementos HTML e causar "Export Injection".* 223 | 224 | > Aprender mais sobre Export Injection: [https://medium.com/@inonst/export-injection-2eebc4f17117](https://medium.com/@inonst/export-injection-2eebc4f17117) 225 | -------------------------------------------------------------------------------------------------------------------------- 226 | 227 | #### -API TIP:26/31- 228 | 229 | *Procurando por BOLA (IDOR) nas APIs? obteve erros 401/403? 230 | Truques para burlar autorização: * 231 | * Enrole a ID com um array` {"id": 111}` --> `{"id": [111]} ` 232 | * JSON wrap `{"id":111}` --> `{"id":{"id":111}}` 233 | * Enviar ID duas vezes `URL?id=&id=` 234 | * Enviar curinga `{"user_id":"*"}` 235 | 236 | > Em alguns casos, o mecanismo de autorização espera uma sequência simples (um ID neste caso) e, se receber um JSON, não executará as verificações de autorização.Em seguida, quando a entrada for para o componente de busca de dados, pode haver um JSON em vez de uma string. 237 | -------------------------------------------------------------------------------------------------------------------------- 238 | 239 | #### -API TIP:27/31- 240 | 241 | *Os servidores de back-end não são mais responsáveis pela proteção contra o XSS. 242 | APIs não retornam HTML, mas JSON. 243 | Se a API retornar o payload do XSS? - 244 | Por exemplo: `{"name":"Inon} ` 245 | Isso é bom! A proteção sempre precisa estar do lado do cliente* 246 | 247 | -------------------------------------------------------------------------------------------------------------------------- 248 | 249 | #### -API TIP:28/31- 250 | 251 | *Pentest para aplicativos .NET? Encontrou um parâmetro que contém o caminho / nome do arquivo? 252 | Às vezes, os desenvolvedores usam "Path.Combine(path_1, path_2)" para criar o caminho completo. 253 | Path.Combine tem um comportamento estranho: se o parâmetro 2 for caminho absoluto, o parâmetro 1 será ignorado.* 254 | ##### Utilize-o para controlar o caminho 255 | 256 | > Saiba mais: [https://www.praetorian.com/blog/pathcombine-security-issues-in-aspnet-applications](https://www.praetorian.com/blog/pathcombine-security-issues-in-aspnet-applications) 257 | -------------------------------------------------------------------------------------------------------------------------- 258 | 259 | #### -API TIP:29/30- 260 | 261 | *As APIs expõem a implementação fundamental do aplicativo. 262 | Os pentesters devem aproveitar esse fato para entender melhor usuários, funções, recursos e correlações entre eles e encontrar vulnerabilidades e exploits. 263 | Sempre tenha curiosidade sobre as respostas da API. * 264 | 265 | -------------------------------------------------------------------------------------------------------------------------- 266 | 267 | #### -API TIP:30/31- 268 | 269 | *Ficou travado durante um teste de API? Expanda sua superfície de ataque! 270 | Se a API tiver clientes móveis, faça o download de versões antigas do arquivo APK para explorar a funcionalidade antiga / herdada e descobrir novos endpoints da API.* 271 | 272 | > Lembre-se: as empresas nem sempre implementam mecanismos de segurança desde o primeiro dia, e os engenheiros do DevOps nem sempre depreciam as APIs antigas. 273 | Aproveite esses fatos para encontrar endpoints da API escondidas que não implementam mecanismo de segurança (autorização, filtragem de entrada e rate limit) 274 | 275 | > Baixe versões antigas do APK de aplicativos para Android: [https://apkpure.com](https://apkpure.com) 276 | -------------------------------------------------------------------------------------------------------------------------- 277 | 278 | #### -API TIP: 31/31- 279 | 280 | *Encontrou um parâmetro `limit` /` page`? (por exemplo: `/api/news?limit=100`) Pode ser vulnerável ao DoS da camada 7. 281 | Tente enviar um valor longo (por exemplo: `limit=999999999`) e veja o que acontece:)* 282 | 283 | -------------------------------------------------------------------------------------------------------------------------- 284 | 285 | ## Fonte 286 | 287 | #### Todas as informações são retiradas do twitter de *Inon Shkedy* 288 | 289 | ##### Links: 290 | 291 | * [Inon Shkedy](https://twitter.com/inonshkedy) 292 | * [Traceableai](https://twitter.com/traceableai/) 293 | * [OWASP API PROJECT](https://github.com/OWASP/API-Security) 294 | -------------------------------------------------------------------------------- /more_tips.md: -------------------------------------------------------------------------------- 1 | Check out the new list of 31 tips: 2 | 3 | https://github.com/Traceableai/31-days-of-pentesting 4 | 5 | https://inonst.medium.com/31-tips-advanced-bug-bounty-pentesting-8ecec2aafffe 6 | --------------------------------------------------------------------------------