API सिक्योरिटी टेस्टिंग
API security testing यह जाँचती है कि API वह सब refuse करे जो उसे refuse करना चाहिए और सिर्फ़ वही लौटाए जिसका caller हक़दार है, जब उसे app की screens से नहीं बल्कि सीधे call किया जाए। API curl को उतनी ही आसानी से जवाब देती है जितनी mobile app को, इसलिए जो भी rule screen पर लागू दिखता है उसे server को दोबारा लागू करना होता है। एक आम finding: app customer को सिर्फ़ उसके अपने invoices दिखाता है, लेकिन number बदलकर भेजा गया GET /v1/invoices/88213 दूसरे customer का invoice लौटा देता है।
इस lesson का test basis OWASP API Security Top 10 (2023) है, दस API security risks की एक awareness list, जिसे OWASP project team ने OWASP Risk Rating Methodology से rank किया: हर weakness को exploit करना कितना आसान है, वह कितनी फैली हुई है और कितनी आसानी से पकड़ी जाती है, और उसका technical impact क्या है। कोई weakness कितनी फैली हुई है, यह team ने आपसी सहमति से तय किया, collected data से नापा नहीं, इसलिए list risks को rank करती है, incidents नहीं गिनती। आप हर risk का मतलब और उसकी एक safe check सीखेंगे, फिर चार पर गहराई से जाएँगे: broken object level authorization (BOLA), broken authentication, excessive data exposure और missing rate limits।
यह क्यों ज़रूरी है
Data API के पास होता है; user interface उसे सिर्फ़ दिखाता है। छिपे हुए buttons और client-side validation उस caller से कुछ नहीं बचाते जो API से सीधे बात करता है, और ज़्यादातर callers यही करते हैं: mobile apps, partner integrations और दूसरी services। एक missing ownership check हर customer के records हर दूसरे customer के सामने खोल देती है; बिना limit वाला एक OTP endpoint किसी script को तब तक codes आज़माने देता है जब तक कोई चल न जाए। ऐसे defects data breaches और fraud बन जाते हैं, cosmetic bugs नहीं।
Tester के लिए अच्छी ख़बर यह है कि इनमें से ज़्यादातर checks वही हैं जो आप पहले से करते हैं, बस थोड़े अलग रूप में: token बदलें, id बदलें, raw response पढ़ें, request दोहराएँ, दो responses की तुलना करें। इनके लिए न scanner चाहिए न exploit skills, और जो functional tester हर नए endpoint पर इन्हें चलाता है वह इनमें से कई defects penetration test से बहुत पहले पकड़ लेता है।
OWASP API Security Top 10 (2023) एक checklist के रूप में
OWASP APIs के लिए अलग Top 10 इसलिए प्रकाशित करता है क्योंकि API के risks web pages के risks से अलग हैं: हमला करने के लिए कोई browser नहीं है, लेकिन हर request में ids हैं, sessions की जगह tokens हैं और छिपाने के लिए कोई screen नहीं। 2023 edition ने 2019 edition की जगह ली और list को फिर से व्यवस्थित किया; 2019 के दो नाम अब भी कई teams इस्तेमाल करती हैं, "Excessive Data Exposure" (अब API3 का हिस्सा) और "Lack of Resources & Rate Limiting" (अब API4), इसलिए यह lesson दोनों नाम देता है।
हर entry को एक सवाल की तरह पढ़ें जो आप हर endpoint के बारे में पूछते हैं, साथ में एक safe check जो आप test environment में अपने test accounts से चला सकते हैं:
- API1:2023 Broken Object Level Authorization (BOLA): API client से आई id पर बिना यह जाँचे भरोसा करती है कि caller को उस object तक पहुँच का हक़ है या नहीं। Check: वही request दूसरे user के token से।
- API2:2023 Broken Authentication: tokens और logins कमज़ोर या असीमित हैं: expiry या logout के बाद भी tokens स्वीकार होते हैं, password या OTP की unlimited attempts, URLs में credentials। Check: missing, expired, revoked और tampered tokens; allowed attempts गिनें।
- API3:2023 Broken Object Property Level Authorization: response में ऐसी properties हैं जो caller को नहीं दिखनी चाहिए (excessive data exposure) या request ऐसी properties set कर सकती है जो उसे नहीं करनी चाहिए (mass assignment)। Check: raw JSON को contract से मिलाएँ; एक extra field भेजें।
- API4:2023 Unrestricted Resource Consumption: request rate, page size, upload size या SMS जैसी पैसे ख़र्च करने वाली operations पर कोई limit नहीं। Check: तेज़ी से दोहराएँ,
pageSize=50000माँगें, maximum से एक byte बड़ा upload करें। - API5:2023 Broken Function Level Authorization: एक role दूसरे role का function call कर सकता है। Check: admin endpoint पर customer token, जैसा API authorization testing के lesson में।
- API6:2023 Unrestricted Access to Sensitive Business Flows: ऐसा flow जो automate होने पर business को नुक़सान पहुँचाता है (सारा stock ख़रीद लेना, हर slot book कर लेना, mass sign-ups) बिना किसी limit, step-up check (CAPTCHA या one-time code जैसा एक अतिरिक्त verification) या review के। Check: एक account से flow को script करें और देखें कि कुछ उसे धीमा करता है या नहीं।
- API7:2023 Server Side Request Forgery (SSRF): server client का दिया हुआ URL, जैसे webhook या image import, बिना allow-list के fetch करता है। Check: अपने control वाला capture URL दें (ऐसा URL जो उस तक आई हर request record करता है, जैसे Webhook Tester का URL) और देखें कि server क्या fetch करता है; private addresses को probe करने के बजाय developer से पूछें कि वे कैसे refuse होते हैं।
- API8:2023 Security Misconfiguration: stack trace वाले verbose errors, TLS के बिना HTTP, किसी भी origin को allow करने वाला CORS, ग़ैर-ज़रूरी methods, default settings। Check: एक malformed request और response headers।
- API9:2023 Improper Inventory Management: पुराने versions और debug endpoints अब भी जवाब देते हैं; OpenAPI document और deployed API अलग हैं। Check:
/v2ship होने के बाद/v1call करें; जो जवाब देता है पर documented नहीं है उसकी list बनाएँ। - API10:2023 Unsafe Consumption of APIs: partner API के data पर बिना validation, size limits या redirect checks के भरोसा किया जाता है। Check: partner को mock करें और bad data लौटाएँ।
| OWASP API entry | क्या ग़लत होता है | एक safe check | Expected |
|---|---|---|---|
| API1:2023Broken Object Level Authorization (BOLA) | Client से आई id पर बिना यह जाँचे भरोसा कि caller उस object तक पहुँच सकता है | वही request उसी role के दूसरे user के token से | 404 या 403; दूसरे user का कोई data नहीं |
| API2:2023Broken Authentication | Expiry या logout के बाद भी tokens स्वीकार; password या OTP की unlimited attempts | बिना token, expired, revoked और tampered token; ग़लत OTP attempts गिनें | WWW-Authenticate के साथ 401, body में कोई data नहीं; कुछ attempts के बाद 429 या lockout |
| API3:2023Broken Object Property Level Authorization | Response में ऐसी properties जो caller को नहीं दिखनी चाहिए (excessive data exposure); request ऐसी properties set कर सकती है जो नहीं करनी चाहिए (mass assignment) | Raw JSON को contract से मिलाएँ; एक valid PATCH में "role": "admin" जोड़ें, फिर object दोबारा पढ़ें | सिर्फ़ contract के fields; 400, या field ignored और अपरिवर्तित |
| API4:2023Unrestricted Resource Consumption | Request rate, page size, upload size या पैसे ख़र्च करने वाली operations पर कोई limit नहीं | तय संख्या में तेज़ी से दोहराएँ; pageSize=50000 माँगें; maximum से एक byte बड़ा upload करें | 429, contract में हो तो Retry-After के साथ; capped page; 400 या 413 |
| API5:2023Broken Function Level Authorization (BFLA) | एक role दूसरे role का function call कर सकता है | Admin endpoint पर customer token, API authorization testing lesson की users × requests matrix से | 403 या 404; कुछ नहीं बदला |
| API6:2023Unrestricted Access to Sensitive Business Flows | Automate होने पर business को नुक़सान पहुँचाने वाले flow पर कोई limit, step-up या review नहीं | एक account से flow को script करें | कुछ उसे धीमा या बंद करता है: limit, step-up, review |
| API7:2023Server Side Request Forgery (SSRF) | Server client का दिया URL बिना allow-list के fetch करता है | अपने control वाला capture URL दें; developer से पूछें कि private addresses कैसे refuse होते हैं | सिर्फ़ allow-listed hosts fetch होते हैं |
| API8:2023Security Misconfiguration | Errors में stack traces, TLS के बिना HTTP, किसी भी origin के लिए CORS, ग़ैर-ज़रूरी methods, default settings | एक malformed request; response headers पढ़ें | Internals के बिना generic error; team से तय headers |
| API9:2023Improper Inventory Management | पुराने versions और debug endpoints अब भी जवाब देते हैं; OpenAPI document और deployed API अलग हैं | /v2 ship होने के बाद /v1 call करें; जो जवाब देता है पर documented नहीं है उसकी list बनाएँ | Retired versions refuse करते हैं; documentation और deployment मेल खाते हैं |
| API10:2023Unsafe Consumption of APIs | Partner API के data पर बिना validation, size limits या redirect checks के भरोसा | Partner को mock करें और bad data लौटाएँ | Validate होकर reject; कोई crash नहीं, कुछ store नहीं |
- इस lesson में गहराई से सिखाया गया
हर check: अपने test accounts, test environment और written permission के साथ; defect साबित करने वाले पहले record पर रुकें।
आज़माएँ: OpenAPI → टेस्ट केस आज़माएँ: Webhook टेस्टर आज़माएँ: API हेडर वैलिडेटर
BOLA और broken authentication: पहले token बदलें, फिर id
BOLA सबसे बड़ा risk इसलिए है क्योंकि APIs में ids हर जगह हैं और caller उस object का owner है या नहीं, यह check हर id के लिए लिखनी पड़ती है। API authorization testing के lesson में users × requests matrix बनी थी; security pass उसे उन ids तक बढ़ाता है जो matrix से अक्सर छूट जाती हैं: ?accountId= जैसी query strings, request bodies, headers, /parcels/7731/label.pdf जैसे nested routes, batch और export endpoints, और file downloads, जो अक्सर अलग code path से serve होते हैं जहाँ कोई check ही नहीं होती। हमेशा एक ही role के दो accounts इस्तेमाल करें, और defect साबित करने वाले पहले record पर रुक जाएँ: आपका काम यह दिखाना है कि check missing है, दूसरों का data इकट्ठा करना नहीं।
API में broken authentication ज़्यादातर tokens और login के आसपास के endpoints की बात है। हर protected endpoint पर request चार तरह से भेजें और हर बार 401 की उम्मीद करें, API authentication के lesson की तरह WWW-Authenticate header के साथ, और body में कोई data या internal detail नहीं: बिना token, expired token, logout कर चुके session का token, और ऐसा token जिसके signature का एक character बदला गया हो। फिर उन endpoints को देखें जो credentials जारी करते हैं:
- Password, OTP और password-reset verification: गिनें कि
429या lockout से पहले API कितनी ग़लत attempts स्वीकार करती है। छह अंकों के OTP की दस लाख संभावित values होती हैं; बिना limit के guessing सिर्फ़ समय की बात है। - JWTs:
"alg": "none"वाला header स्वीकार नहीं होना चाहिए, और किसी दूसरे audience के लिए जारी हुआ token, या ऐसे issuer का token जिस पर API भरोसा नहीं करती, refuse होना चाहिए; RFC 8725 (JWT Best Current Practices) ये checks बताता है। JWT Header Analyzer और JWT Claims Analyzer दिखाते हैं कि token क्या claim करता है, इससे पहले कि आप टेस्ट करें कि API उसके साथ क्या करती है। - Error bodies: "wrong password" और "no such account" एक जैसे पढ़ने चाहिए, वरना login endpoint बता देता है कि कौन-से accounts मौजूद हैं।
- Credentials और tokens की जगह URLs, logs या error messages में कभी नहीं है; query string में गया token हर proxy के log में पहुँच जाता है।
# One protected request, four ways.
# Expected: 401 each time, with WWW-Authenticate and no data in the body
GET /v1/users/me HTTP/1.1
Host: api.example.test
# 1. no Authorization header
# 2. Authorization: Bearer <expired token>
# 3. Authorization: Bearer <token of a session that has logged out>
# 4. Authorization: Bearer <valid token with one signature character changed>
# OTP verification: send code 000001, then 000002, 000003 ...
# Expected: 429 or a lockout after a small number of attempts
POST /v1/auth/otp/verify HTTP/1.1
Host: api.example.test
Content-Type: application/json
{"phone": "+9665XXXXXXXX", "code": "000001"}आज़माएँ: API ऑथेंटिकेशन टेस्टर आज़माएँ: JWT हेडर एनालाइज़र आज़माएँ: JWT क्लेम एनालाइज़र
Excessive data exposure और missing rate limits
Excessive data exposure तब होता है जब API पूरा object लौटा देती है और client पर भरोसा करती है कि वह उसका सिर्फ़ एक हिस्सा दिखाएगा। Profile screen नाम और avatar दिखाती है; raw response में e-mail address, phone number, national id, internal notes या password hash भी होता है। 2023 edition इस risk को mass assignment के साथ API3 में मिला देता है, क्योंकि दोनों एक ही missing सवाल हैं: क्या यह caller यह property देख, या set कर सकता है? Read side को हर raw response की contract से तुलना करके टेस्ट करें, जैसा API schema validation के lesson में, और हर field के लिए पूछें कि क्या इस role को इसकी ज़रूरत है। Write side को टेस्ट करने के लिए एक otherwise valid PATCH या POST में ऐसी property जोड़ें जिस पर caller का control नहीं होना चाहिए, "role": "admin", "balance": 9999 या "verified": true, फिर object को दोबारा पढ़ें: सही नतीजे हैं 400, या field का चुपचाप ignore होना और बदला न होना।
Rate limits उन resources की रक्षा करती हैं जिन्हें हर request खर्च करती है: CPU, memory, bandwidth, database connections और पैसा, जब कोई endpoint SMS भेजता है या paid service call करता है। इनके बिना एक client सबके लिए service ख़त्म कर सकता है या ऊपर बताए guessing attacks चला सकता है। RFC 6585 इसके लिए 429 Too Many Requests परिभाषित करता है और कहता है कि response में Retry-After header हो सकता है। एक safe test के तीन हिस्से हैं, और एक जगह:
- Rate: वही request तेज़ी से भेजें, team से तय संख्या में, और दर्ज करें कि पहला
429किस request number पर आया, उसके साथ कौन-से headers आए, और limit per user है, per API key है या per IP address, क्योंकि सिर्फ़ IP वाली limit client के address बदलते ही फिर से शुरू हो जाती है। - Size:
?pageSize=50000माँगें, documented maximum से एक byte बड़ी body भेजें या upload करें, और JSON body को किसी भी client से ज़्यादा गहरा nest करें।400या413और capped page की उम्मीद करें, 50000 rows वाला response कभी नहीं। - Cost: जो endpoints SMS या e-mail भेजते हैं या partner call करते हैं, उन पर पक्का करें कि per-user daily limit मौजूद है और उसे server लागू करता है, app नहीं।
- जगह: सिर्फ़ ऐसा test environment जिस पर load डालने की आपको अनुमति है, team से तय संख्याओं के साथ, क्योंकि test खुद एक load है; production पर कभी नहीं और किसी और के system पर कभी नहीं।
आज़माएँ: API रिस्पॉन्स एनालाइज़र आज़माएँ: API स्कीमा वैलिडेटर आज़माएँ: API रिक्वेस्ट बिल्डर
Worked example: एक telecom self-service API पर security pass
Test environment में एक telecom self-service API, अपनी-अपनी test lines वाले दो customer accounts A और B, एक OpenAPI document और team की written permission। Plan में पाँच endpoints और ऊपर के चार risks हैं; expected results पहली request से पहले contract से लिखे गए। आठ checks में से छह ने defects पकड़े:
- C1, BOLA:
GET /v1/accounts/A/invoicesपर B के token ने404की जगह A के invoices के साथ200लौटाया। Critical: कोई भी customer किसी भी customer के invoices पढ़ सकता है। - C3, broken authentication: logout कर चुके session का token अब भी स्वीकार हुआ; logout ने उसे सिर्फ़ device से हटाया था। Major।
- C4, broken authentication: लगातार 50 ग़लत OTP codes, सब
400, न429न lockout। Critical: login code guess किया जा सकता है। - C5, excessive data exposure:
GET /v1/users/meनेnationalIdऔरpasswordHashलौटाए, जिनमें से कोई contract में नहीं है। Critical: identity data और password hash किसी भी client तक पहुँचते हैं। - C6, mass assignment:
"planTier": "premium"के साथPATCH /v1/users/meने200लौटाया, और नएGETमें plan upgraded दिखा। Major, financial impact के साथ। - C7, resource consumption: A की test line के usage records पर
?pageSize=50000ने सारे 12000 records एक ही page में, नौ seconds में लौटाए; contract की limit (100) लागू नहीं थी। Major।
Telecom self-service API, test environment. Customers A and B, each with a test line.
# Risk Request (actor) Expected Observed
C1 API1 B: GET /v1/accounts/A/invoices 404 200, A's invoices
C2 API2 no token: GET /v1/users/me 401 401
C3 API2 A after logout: GET /v1/users/me 401 200
C4 API2 POST /v1/auth/otp/verify, 50 wrong codes 429 early 50 x 400, no lockout
C5 API3 A: GET /v1/users/me, fields vs contract contract 2 extra fields
C6 API3 A: PATCH /v1/users/me {"planTier":"premium"} 400/ignored 200, plan upgraded
C7 API4 A: GET /v1/accounts/A/usage?pageSize=50000 100 rows 12000 rows, 9 s
C8 API4 A: GET /v1/accounts/A/invoices, 60 in 10 s 429 after 30 429 from request 31आम गलतियाँ
- सिर्फ़ app की screens से टेस्ट करना, जिससे आप raw response कभी नहीं देखते और ऐसी request कभी नहीं भेजते जो app नहीं भेजेगा।
- हर role का एक ही account इस्तेमाल करना, जिससे object-level tests असंभव हो जाते हैं, या असली customer accounts और data इस्तेमाल करना।
- सिर्फ़ status code से फ़ैसला करना: ऐसा
403जिसकी body में object अब भी है, एक leak है, और200यह नहीं बताता कि कोई forbidden field save हुआ या नहीं; body और stored state भी पढ़ें। - Random UUIDs या undocumented endpoints को protection मानना: ids links, logs और दूसरे responses से leak होती हैं, और हर endpoint app के traffic में दिखता है।
- Rate-limit और size tests production या shared environment पर चलाना, या team से संख्याएँ तय किए बिना।
- "Scanner को कुछ नहीं मिला" पर रुक जाना: scanner आपकी access policy नहीं जानता, इसलिए BOLA और property-level defects सिर्फ़ उससे लिखे tests से मिलते हैं।
- Security defect को ticket में असली tokens या personal data के साथ, या OWASP category और severity के बिना report करना।
QA का नज़रिया
किसी नए या बदले endpoint के functional API tests design करते समय ही security rows plan करें, OpenAPI document को test basis बनाकर, और उन्हें उसी data-driven suite में रखें ताकि वे pipeline में चलें। Developer से पूछें कि हर role को कौन-से fields चाहिए, rate limit कहाँ लागू होती है और उसके numbers क्या हैं, कौन-से versions अब भी deployed हैं और logout के बाद token का क्या होता है; product owner से पूछें कि कौन-से business flows automate नहीं होने चाहिए; और जो इस scope से बाहर है, जैसे exploitation या infrastructure, उसे security team या penetration tester को सौंपें।
हर check के लिए endpoint, actor और object का owner, request, expected और observed result, state check और OWASP API entry दर्ज करें, tokens और personal data mask करके, और security defects restricted ticket में file करें, public board पर नहीं। सिर्फ़ उन्हीं systems को टेस्ट करें जो आपके हैं या जिनकी written permission है, और defect साबित करने वाले पहले record पर रुक जाएँ: tester दिखाता है कि check missing है; बात साबित करने के लिए दूसरों का data निकालना न ज़रूरी है न allowed।
अभ्यास
Parcel-delivery API के लिए security pass plan करें
Test environment में एक parcel-delivery API। Customers parcels बनाते हैं और अपने parcels की सिर्फ़ delivery notes बदल सकते हैं; couriers उन्हें assigned parcels देखते हैं; contract उन parcels को 404 से छिपाता है जिन्हें caller नहीं देख सकता, pageSize को 50 पर cap करता है और हर phone number पर प्रति घंटे दस OTP attempts allow करता है। आपके पास customer accounts A और B, courier account C और written permission है। Parcel 7731 A ने भेजा है और C को assigned है।
नीचे के पाँच endpoints के लिए हर risk की एक safe check plan करें, फिर तीन observed results को परखें।
Parcel API, test environment. Parcel 7731: sender A, courier C.
E1 GET /v1/parcels/{id} details: address, phone, items, price
E2 GET /v1/parcels/{id}/label.pdf shipping label download
E3 POST /v1/auth/otp/verify {"phone": "...", "code": "123456"}
E4 PATCH /v1/parcels/{id} {"notes": "..."}
E5 GET /v1/parcels?pageSize=50 the caller's parcels
Observed:
O1 B: GET /v1/parcels/7731 -> 404
O2 A: PATCH /v1/parcels/7731 -> 200, status DELIVERED
{"notes": "ring the bell", "status": "DELIVERED"}
O3 POST /v1/auth/otp/verify, 30 wrong codes in 20 s -> 30 x 400, then 429- हर endpoint E1 से E5 के लिए जाँचने लायक OWASP API Security Top 10 entries बताएँ; एक से ज़्यादा लागू हो सकती हैं।
- हर entry के लिए एक safe check लिखें: actor, request, expected result।
- O1 से O3 को परखें: correct या defect, OWASP entry और severity के साथ।
- एक ऐसी check बताएँ जो इस environment में बिना agreement नहीं चलानी चाहिए, और क्यों।
मॉडल उत्तर दिखाएँ
E1: API1 (B का token → 404; C का token → 200; C को assigned न हुए parcel पर C → 404) और API3 (क्या courier को price चाहिए? raw fields की तुलना हर role की ज़रूरत से करें)। E2: फिर से API1, क्योंकि downloads अक्सर check छोड़ देते हैं, और API8 अगर label URL बिना token चलता है। E3: API2 और API4 (ग़लत code और unknown phone पर एक जैसी generic body; ग्यारहवीं attempt तक 429)। E4: API3 (extra "status" reject या ignore होना चाहिए और re-read पर अपरिवर्तित) और API1 (7731 पर B → 404, parcel अपरिवर्तित)। E5: API4 (pageSize=50000 → 50 पर capped या 400) और API1 (B की list में 7731 नहीं होना चाहिए, ?senderId=A जोड़ने पर भी)।
O1 correct है। O2 defect है: mass assignment, API3, एक customer ने अपना parcel delivered mark कर दिया; major, और critical अगर delivery status से couriers का payment तय होता है। O3 defect है: contract हर phone पर प्रति घंटे दस attempts allow करता है और API ने तीस allow कीं; API2 और API4, major; यह भी पूछें कि limit per phone number है या per IP address, क्योंकि सिर्फ़ IP वाली limit client के address बदलते ही फिर से शुरू हो जाती है।
बिना agreement नहीं: E3 और E5 पर बड़े पैमाने के rate और size tests, क्योंकि वे shared environment पर load डालते हैं; team से संख्याएँ और time window तय करें, और इन्हें production पर कभी न चलाएँ।
अक्सर पूछे जाने वाले सवाल
क्या यह penetration test जैसा ही है?
नहीं। Penetration test विशेषज्ञ करते हैं जिनके पास exploit करने, findings को chain करने और infrastructure व अक्सर production को cover करने की permission होती है। यहाँ की checks वह safe हिस्सा हैं जो functional tester access policy और contract से हर endpoint के लिए चलाता है, ताकि penetration test पहली बार न हो जब कोई id बदले।
क्या API security टेस्ट करने के लिए scanner चाहिए?
Scanners misconfiguration, missing headers और known patterns पकड़ते हैं, और अगला lesson दिखाता है कि वे कहाँ fit होते हैं। वे यह नहीं जान सकते कि order 9021 customer A का है या courier को prices नहीं दिखने चाहिए, इसलिए BOLA, function-level और property-level defects सिर्फ़ policy से लिखे tests से मिलते हैं, और यही यह lesson सिखाता है।
हमारी documentation अब भी "Excessive Data Exposure" और "Lack of Resources & Rate Limiting" कहती है। क्या ये ग़लत हैं?
ये 2019 के नाम हैं। 2023 edition में excessive data exposure और mass assignment मिलकर API3:2023 Broken Object Property Level Authorization बने, और lack of resources and rate limiting API4:2023 Unrestricted Resource Consumption बना। Reports में current ids इस्तेमाल करें और जब तक team अभ्यस्त न हो, पुराना नाम brackets में जोड़ें।
Limit hit होने पर API को क्या लौटाना चाहिए?
RFC 6585 429 Too Many Requests परिभाषित करता है और कहता है कि response को condition समझानी चाहिए और उसमें Retry-After header हो सकता है। Page-size cap के लिए माँगी गई से कम rows चुपचाप लौटाने वाला 200 तब स्वीकार्य है जब contract ऐसा कहे; 500 या timeout एक defect है: limit missing है या टिकती नहीं।
संदर्भ
- OWASP API Security Top 10 (2023)API की दस सबसे आम कमज़ोरियाँ: ऑब्जेक्ट-लेवल ऑथराइज़ेशन का टूटना, ऑथेंटिकेशन का टूटना, अनियंत्रित रिसोर्स खपत और अन्य।
- OWASP Cheat Sheet Series: REST SecurityREST API के सुरक्षा नियम: HTTPS, हर रिक्वेस्ट पर ऑथेंटिकेशन, इनपुट वैलिडेशन, सुरक्षित एरर रिस्पॉन्स, रेट लिमिटिंग।
- RFC 6585: Additional HTTP Status Codes428, 429 Too Many Requests, 431 और 511 को परिभाषित करता है, रेट लिमिटिंग के लिए Retry-After हेडर सहित।
- RFC 8725: JSON Web Token Best Current PracticesJWT इम्प्लीमेंटेशन के सुरक्षा नियम: alg=none अस्वीकार करें, एल्गोरिद्म पिन करें, iss/aud जाँचें, छोटी अवधि रखें।
Mutqan tools से अभ्यास करें
किसी endpoint पर Bearer, Basic, API-key और कस्टम-हेडर प्रमाणीकरण टेस्ट करें और अधिकृत बनाम अनधिकृत रिस्पॉन्स की तुलना करें।
JWT का JOSE हेडर जाँचें: alg, typ, kid, jku, x5u और एल्गोरिदम-कन्फ़्यूज़न के संभावित जोखिम।
JWT क्लेम में गायब, जोखिम भरी या ग़ैर-मानक वैल्यू जाँचें और सुरक्षा संबंधी सुझाव पाएँ।
किसी API रिस्पॉन्स का विश्लेषण करें: संरचना, फ़ील्ड टाइप, null, डुप्लिकेट, साइज़ और संभावित डेटा-क्वालिटी समस्याएँ।
method, हेडर और JSON बॉडी पर पूरे नियंत्रण के साथ REST endpoint टेस्ट करें, फिर स्टेटस, हेडर और JSON path पर assertion लगाएँ।
OpenAPI / Swagger स्पेसिफ़िकेशन से संरचित टेस्ट-केस मैट्रिक्स (positive, negative, auth, boundary) बनाएँ।
और गहराई से
इस topic में आपकी प्रगति
प्रगति ट्रैक करने के लिए साइन इन करें
Topics पूर्ण चिह्नित करें, जहाँ छोड़ा था वहीं से जारी रखें और specialisation परीक्षाएँ खोलें।