الـ Passkeys و WebAuthn: login من غير password وضد الـ phishing

جارٍ التحميل…

01 / ملخص الدرس

الـ Passkeys و WebAuthn: login من غير password وضد الـ phishing

بنبني authenticator software بيعمل نفس اللي الموبايل بيعمله (P-256 و CBOR و authenticatorData وتوقيع)، و server بـ @simplewebauthn/server. بنفهم الـ registration والـ authentication ceremonies، و rpId والـ origin وليه الـ phishing ما بيعدّيش، والـ discoverable credentials، والـ counter والـ synced passkeys. وبنشوف تلات غلطات في الـ server: replay، وتبديل المستخدم، ونسخ الجهاز. والتحدي: server كامل آمن.

02 / شرح الدرس مكتوبًا

نص شرح المعلم والكود الذي كتبه ونتيجة تشغيله، بنفس ترتيب الدرس.

أهلًا بيك. الدرس اللي فات خلص بمشكلة: الـ TOTP بيتسرق بالـ phishing، لأن المستخدم بنفسه بيكتب الـ code في الموقع المزيّف. الـ passkeys بتحل ده بفكرة بسيطة: مفيش سر بيتكتب. الجهاز عنده private key ما بيخرجش منه أبدًا، والـ server عنده الـ public key بس. كل login، الـ server بيبعت challenge عشوائي، والجهاز بيوقّعه بعد بصمة أو PIN. والأهم: الـ key مربوط بالـ domain. الموبايل مش هيوقّع لموقع غير اللي اتسجّل عليه، والمتصفح هو اللي بيكتب الـ origin الحقيقي جُوّه الحاجة اللي بتتوقّع. الـ standard اسمه WebAuthn، وجزء من حاجة أكبر اسمها FIDO2. علشان نجرّب من غير متصفح حقيقي، authenticator dot js بيعمل اللي الموبايل بيعمله بالضبط، بنفس الـ formats: create، يعني الـ registration: بيعمل key pair من نوع P-256، ويحفَظ الـ private key ومعاه الـ rpId والـ userHandle. وبيرجّع authenticatorData فيها hash الـ rpId، و flags: UP يعني المستخدم موجود، و UV يعني اتأكد ببصمة أو PIN. وفيها الـ public key مكتوب CBOR بـ format اسمه COSE. get، يعني الـ login: بيدوّر على passkey للـ rpId ده، ويزوّد الـ counter، ويوقّع على الـ authenticatorData ومعاها hash الـ clientDataJSON. و scope: ده دور المتصفح. صفحة على domain معيّن ما تقدرش تطلب rpId لـ domain تاني. و clone بيعمل نسخة من الجهاز، كأن malware نسخ الـ keys.

browser dot js بيوصّل الـ server بالـ authenticator: register: يجيب options من الـ server، ويدّيها للجهاز، ويرجّع الرد. login نفس الفكرة. و server dot js بيستخدم مكتبة at simplewebauthn slash server، ودي اللي بتعمل الـ parsing والتأكد من التوقيع. الـ server فيه أربع endpoints: options و verify للـ register، ونفسهم للـ login. وفيه تلات غلطات: الـ challenge متخزن على الـ username وما بيتمسحش. الـ login بيجيب أي credential بالـ id، وبيعمل session للـ username اللي جاي في الـ body. والـ counter ما بيتحفَظش، و requireUserVerification false. attack dot js: مُنى بتسجّل موبايلها وتعمل login. وبعدين أربع هجمات. نشغّل.

attack.js
import { browser } from "./browser.js";
import { createAuthenticator } from "./authenticator.js";
const log = (s, ...x) => console.log(s.padEnd(40), ...x);
const tryIt = async (fn) => { try { return await fn(); } catch (e) { return e.message; } };

const phone = createAuthenticator("موبايل مُنى");
const mona = browser();
await mona.register(phone, "mona");
const first = await mona.login(phone, "mona");
log("مُنى login عادي:", first.status, first.body);

// 1) replay: المهاجم شاف الـ response بتاع مُنى (log أو proxy) وبعته تاني
const thief = browser();
const replay = await thief.send("/login/verify", { username: "mona", response: first.response });
log("1) replay لنفس الـ response:", replay.status, replay.body);

// 2) عمر عنده passkey على حسابه هو، وبيقول إنه mona
const laptop = createAuthenticator("لابتوب عمر");
const omar = browser();
await omar.register(laptop, "omar");
const opts = (await omar.send("/login/options", { username: "mona" })).body;
const omarSig = await laptop.get({ ...opts, allowCredentials: [] }, "http://localhost:3000");
const swap = await omar.send("/login/verify", { username: "mona", response: omarSig });
log("2) credential عمر + username mona:", swap.status, swap.body, (await omar.me()).body);

// 3) نسخة من موبايل مُنى (malware نسخ الـ keys)، ومُنى لسه بتستخدم الأصلي
const copy = phone.clone();
for (let i = 0; i < 3; i++) await mona.login(phone, "mona");
const cl = await tryIt(() => browser().login(copy, "mona"));
log("3) النسخة القديمة من الجهاز:", cl.status, cl.body);

// 4) phishing: صفحة مزيّفة على baassma-login.com بتمرّر الـ challenge من الموقع الحقيقي
const evil = browser("https://baassma-login.com");
const real = (await evil.send("/login/options", { username: "mona" })).body;
log("4) الصفحة المزيّفة بـ rpId الحقيقي:", await tryIt(() => phone.get(real, "https://baassma-login.com")));
log("   الصفحة المزيّفة بـ rpId بتاعها:", await tryIt(() => phone.get({ ...real, rpId: "baassma-login.com" }, "https://baassma-login.com")));

المخرجات

$ node --no-warnings server.js & sleep 1; node attack.js; kill $!
API: http://localhost:3000
مُنى login عادي:                         200 { verified: true, user: 'mona' }
1) replay لنفس الـ response:             200 { verified: true, user: 'mona' }
2) credential عمر + username mona:       200 { verified: true, user: 'mona' } { user: 'mona' }
3) النسخة القديمة من الجهاز:             200 { verified: true, user: 'mona' }
4) الصفحة المزيّفة بـ rpId الحقيقي:      SecurityError: baassma-login.com مش مسموحله يطلب rpId=localhost
   الصفحة المزيّفة بـ rpId بتاعها:       NotAllowedError: مفيش passkey لـ baassma-login.com على موبايل مُنى

واحد: الـ replay نجح، لأن نفس الـ challenge لسه صالح. اتنين: عمر وقّع بالـ passkey بتاعه هو، والـ server صدّق التوقيع، وبعدين عمله session باسم mona. التوقيع سليم فعلًا، بس بتاع حد تاني. تلاتة: النسخة القديمة من الجهاز اتقبلت. أربعة، وده المهم: الـ phishing فشل حتى مع الـ server الغلط. الصفحة المزيّفة لما طلبت الـ rpId الحقيقي، المتصفح رفض. ولما طلبت الـ rpId بتاعها، الموبايل ما لقاش passkey أصلًا. يعني المستخدم ما يقدرش يتضحك عليه حتى لو عايز.

قواعد الـ server. challenge واحد لكل ceremony، عشوائي من الـ server، مربوط بالمتصفح ده، وبيتمسح أول ما يتستخدم، وعمره دقايق. المستخدم بيتحدد من الـ credential، والـ userHandle لازم يطابق. الـ counter: لو الجهاز بيعدّ والرقم رجع لورا، يبقى فيه نسخة. بس الـ synced passkeys، زي iCloud Keychain و Google Password Manager، الـ counter فيها دايمًا صفر، لأن الـ key نفسه بيتنسخ بين أجهزتك عن قصد. و backedUp بيقولك ده synced ولا لأ. residentKey required: الـ passkey بيتخزن على الجهاز ومعاه المستخدم، فالـ login يبقى من غير username، وده اسمه discoverable credential. excludeCredentials: ما يتسجّلش نفس الجهاز مرتين. و attestation none: أغلب المواقع مش محتاجة تعرف نوع الجهاز. البنوك أحيانًا بتطلبه. التحدي: اكتب الـ server صح. ceremonies بـ begin و take. الـ register بـ excludeCredentials و residentKey و UV. الـ login usernameless، والمستخدم من الـ credential، والـ userHandle يطابق، والـ counter يتحفَظ. test dot js فيه حداشر حالة، والتفاصيل في الكومنت.

تمرين

ceremonies (challenge لكل محاولة في cookie، one-time، خمس دقايق)، و register بـ excludeCredentials و residentKey/UV required، و login usernameless: المستخدم من الـ credential، والـ userHandle يطابق، والـ counter يتحدّث.

الحل. begin بيعمل cid ويحطه في cookie، و take بيمسحه قبل ما يرجّعه. الـ register بيحفَظ الـ deviceType والـ backedUp كمان، علشان تعرض للمستخدم أجهزته. الـ login options من غير username. والـ verify: ceremony، وبعدين credential معروف، وبعدين المكتبة بتشيك التوقيع والـ challenge والـ origin والـ rpId والـ counter، وبعدين احنا بنشيك الـ userHandle، ونغيّر الـ counter للرقم الجديد، ونعمل session لصاحب الـ credential. نشغّل الهجمات تاني.

server.js
import express from "express";
import crypto from "node:crypto";
import {
  generateRegistrationOptions,
  verifyRegistrationResponse,
  generateAuthenticationOptions,
  verifyAuthenticationResponse,
} from "@simplewebauthn/server";

const RP_ID = "localhost"; // الـ domain بتاعك. الـ passkey بيتربط بيه للأبد
const ORIGIN = "http://localhost:3000";
const app = express();
app.use(express.json());

const users = new Map(); // username → { webauthnId, credentials: [] }
const credentials = new Map(); // credential id → { id, publicKey, counter, transports, owner }
const sessions = new Map();
const cookie = (req, name) => req.get("cookie")?.match(new RegExp(`(?:^|; )${name}=([^;]+)`))?.[1];
const startSession = (res, username) => {
  const sid = crypto.randomBytes(32).toString("base64url");
  sessions.set(sid, username);
  res.append("Set-Cookie", `sid=${sid}; HttpOnly; Secure; SameSite=Lax; Path=/`);
};
const getUser = (username) => {
  if (!users.has(username)) users.set(username, { webauthnId: crypto.randomBytes(16), credentials: [] });
  return users.get(username);
};
app.get("/me", (req, res) => res.json({ user: sessions.get(cookie(req, "sid")) ?? null }));

// كل ceremony ليها challenge واحد، مربوط بالمتصفح ده بـ cookie، وبيتمسح أول ما يتستخدم
const ceremonies = new Map(); // cid → { type, challenge, username, exp }
const begin = (res, data) => {
  const cid = crypto.randomBytes(16).toString("base64url");
  ceremonies.set(cid, { ...data, exp: Date.now() + 5 * 60_000 });
  res.append("Set-Cookie", `wa=${cid}; HttpOnly; Secure; SameSite=Strict; Path=/`);
};
const take = (req, type) => {
  const cid = cookie(req, "wa");
  const c = ceremonies.get(cid);
  ceremonies.delete(cid);
  return c && c.type === type && Date.now() < c.exp ? c : null;
};

app.post("/register/options", async (req, res) => {
  // في الحقيقة: مستخدم جديد، أو مستخدم عامل login وبيضيف passkey
  const username = String(req.body.username ?? "");
  const user = getUser(username);
  const options = await generateRegistrationOptions({
    rpName: "Baassma",
    rpID: RP_ID,
    userName: username,
    userID: user.webauthnId,
    attestationType: "none",
    excludeCredentials: user.credentials.map((id) => ({ id, transports: credentials.get(id).transports })),
    authenticatorSelection: { residentKey: "required", userVerification: "required" },
  });
  begin(res, { type: "register", challenge: options.challenge, username });
  res.json(options);
});

app.post("/register/verify", async (req, res) => {
  const c = take(req, "register");
  if (!c) return res.status(400).json({ error: "ابدأ من الأول" });
  try {
    const { verified, registrationInfo } = await verifyRegistrationResponse({
      response: req.body.response,
      expectedChallenge: c.challenge,
      expectedOrigin: ORIGIN,
      expectedRPID: RP_ID,
      requireUserVerification: true,
    });
    const cred = registrationInfo?.credential;
    if (!verified || credentials.has(cred.id)) return res.status(400).json({ error:
…

المخرجات

$ node --no-warnings server.js & sleep 1; node attack.js; kill $!
API: http://localhost:3000
مُنى login عادي:                         200 { verified: true, user: 'mona' }
رفضنا: مفيش ceremony أو اتستخدمت (replay)
1) replay لنفس الـ response:             401 { error: 'الدخول فشل' }
2) credential عمر + username mona:       200 { verified: true, user: 'omar' } { user: 'omar' }
رفضنا: Response counter value 2 was lower than expected 4
3) النسخة القديمة من الجهاز:             401 { error: 'الدخول فشل' }
4) الصفحة المزيّفة بـ rpId الحقيقي:      SecurityError: baassma-login.com مش مسموحله يطلب rpId=localhost
   الصفحة المزيّفة بـ rpId بتاعها:       NotAllowedError: مفيش passkey لـ baassma-login.com على موبايل مُنى

الـ replay: الـ ceremony اتمسحت. عمر دخل، بس دخل عمر، مش mona. النسخة: الـ counter رجع لورا، والمكتبة رفضت. ونشغّل test dot js.

server.js

المخرجات

$ node --no-warnings server.js & sleep 1; node test.js; kill $!
API: http://localhost:3000
✅ register مُنى ← verified 
✅ نفس الموبايل مرة تانية ← InvalidStateError 
✅ login من غير username ← mona 
✅ /me ← mona 
رفضنا: مفيش ceremony أو اتستخدمت (replay)
✅ replay لنفس الـ response ← 401 
رفضنا: Unexpected authentication response challenge "Il8OuMqU6pgTiouvy6Y2M2q_N9XkjsbIyCxr6ylG4Oo"
✅ replay حتى مع ceremony جديدة ← 401 
✅ عمر بيقول mona ← بيدخل omar بس 
رفضنا: Response counter value 2 was lower than expected 3
✅ نسخة قديمة من الجهاز (counter أقل) ← 401 
رفضنا: credential مش معروف
✅ credential مش معروف ← 401 
✅ من غير ceremony ← 400 في الـ register 
✅ phishing ← المتصفح رفض 

11/11 نجحوا

كله نجح. في الإنتاج: خلّي المستخدم يسجّل أكتر من passkey، واحد على الموبايل وواحد على اللابتوب. اعرضله list بأجهزته وخلّيه يمسح أي واحد. و recovery بنفس قواعد الدرس اللي فات. وبكده خلصنا قسم الـ Authentication. القسم الجاي: الأمن التطبيقي، وأول درس فيه: threat modeling بـ STRIDE، إزاي تفكّر زي المهاجم قبل ما تكتب ولا سطر.

authenticator.js
// authenticator.js: passkey software، بيعمل اللي الموبايل أو الـ security key بيعمله، بالضبط بنفس الـ formats
import crypto from "node:crypto";

const sha = (b) => crypto.createHash("sha256").update(b).digest();
const u32 = (n) => Buffer.from([(n >>> 24) & 255, (n >> 16) & 255, (n >> 8) & 255, n & 255]);
const head = (major, n) =>
  n < 24 ? [(major << 5) | n] : n < 256 ? [(major << 5) | 24, n] : [(major << 5) | 25, n >> 8, n & 255];
// CBOR صغير: الـ format اللي الـ attestationObject والـ public key مكتوبين بيه
const cbor = (v) => {
  if (typeof v === "number") return Buffer.from(v >= 0 ? head(0, v) : head(1, -1 - v));
  if (typeof v === "string") return Buffer.concat([Buffer.from(head(3, Buffer.byteLength(v))), Buffer.from(v)]);
  if (v instanceof Uint8Array) return Buffer.concat([Buffer.from(head(2, v.length)), v]);
  const entries = v instanceof Map ? [...v] : Object.entries(v);
  return Buffer.concat([Buffer.from(head(5, entries.length)), ...entries.flatMap(([k, x]) => [cbor(k), cbor(x)])]);
};

export function createAuthenticator(name) {
  const creds = []; // { id, rpId, userHandle, privateKey, counter }
  // المتصفح هو اللي بيكتب الـ origin الحقيقي بتاع الصفحة، والموقع ما يقدرش يغيّره
  const scope = (origin, rpId) => {
    const host = new URL(origin).hostname;
    if (host !== rpId && !host.endsWith("." + rpId)) throw new Error(`SecurityError: ${host} مش مسموحله يطلب rpId=${rpId}`);
  };
  return {
    name,
    async create(options, origin) {
      const rpId = options.rp.id;
      scope(origin, rpId);
      if (options.excludeCredentials?.some((c) => creds.some((x) => x.id === c.id)))
        throw new Error("InvalidStateError: الجهاز ده متسجّل قبل كده");
      const { privateKey, publicKey } = crypto.generateKeyPairSync("ec", { namedCurve: "P-256" });
      const { x, y } = publicKey.export({ format: "jwk" });
      const raw = crypto.randomBytes(16);
      const id = raw.toString("base64url");
      creds.push({ id, rpId, userHandle: options.user.id, privateKey, counter: 0 });
      // COSE key: kty=EC2، alg=ES256، crv=P-256، x، y
      const cose = new Map([[1, 2], [3, -7], [-1, 1], [-2, Buffer.from(x, "base64url")], [-3, Buffer.from(y, "base64url")]]);
      const flags = 0x01 | 0x04 | 0x40; // UP (المستخدم موجود) + UV (بصمة/PIN) + AT (فيه credential جديد)
      const authData = Buffer.concat([sha(rpId), Buffer.from([flags]), u32(0), Buffer.alloc(16), Buffer.from([0, raw.length]), raw, cbor(cose)]);
      const clientData = { type: "webauthn.create", challenge: options.challenge, origin, crossOrigin: false };
      return {
        id,
        rawId: id,
        type: "public-key",
        response: {
          clientDataJSON: Buffer.from(JSON.stringify(clientData)).toString("base64url"),
          attestationObject: cbor({ fmt: "none", attStmt: {}, authData }).toString("base64url"),
          transports: ["internal", "hybrid"],
        },
        clientExtensionResults: {},
        authenticatorAttachment: "platform",
      };
 
…
browser.js
// browser.js: متصفح صغير: cookies + بيوصّل الـ server بالـ authenticator
export const browser = (origin = "http://localhost:3000") => {
  let cookies = {};
  const send = async (path, body) => {
    const r = await fetch("http://localhost:3000" + path, {
      method: body === undefined ? "GET" : "POST",
      headers: { "content-type": "application/json", cookie: Object.entries(cookies).map(([k, v]) => `${k}=${v}`).join("; ") },
      body: body === undefined ? undefined : JSON.stringify(body),
    });
    for (const sc of r.headers.getSetCookie()) {
      const [kv] = sc.split(";");
      const i = kv.indexOf("=");
      cookies[kv.slice(0, i)] = kv.slice(i + 1);
    }
    return { status: r.status, body: await r.json().catch(() => null) };
  };
  return {
    send,
    async register(device, username) {
      const opts = (await send("/register/options", { username })).body;
      const response = await device.create(opts, origin);
      return send("/register/verify", { username, response });
    },
    async login(device, username) {
      const opts = (await send("/login/options", { username })).body;
      const response = await device.get(opts, origin);
      return { ...(await send("/login/verify", { username, response })), response };
    },
    me: () => send("/me"),
  };
};
03 / دروس المسار (122)
  1. 01أهلًا بيك: يعني إيه backend، والكورس ده ماشي إزاي
  2. 02الملفات والفولدرات والـ terminal: تتحرك على جهازك زي المبرمجين
  3. 03Node وأول برنامج: تشغّل وتقرا رسالة الخطأ
  4. 04القيم والمتغيرات والأنواع: const و let و typeof
  5. 05القرارات والتكرار: if و === والـ truthy والـ loops
  6. 06الـ functions: parameters و return والـ arrow functions والـ scope
  7. 07الـ objects والـ arrays: destructuring و spread و map و filter و reduce
  8. 08JSON والنصوص والتواريخ: اللغة اللي الـ backend بيتكلم بيها
  9. 09الـ callbacks والـ closures وأول لمسة async: setTimeout
  10. 10الـ classes والـ errors: throw و try/catch و stack trace
  11. 11git: تحفَظ كل خطوة وترجعلها، وما تسرّبش أسرارك
  12. 12ESM و CommonJS و package exports: Node بيلاقي الـ modules إزاي
  13. 13الـ Promises و async/await: sequential و parallel والأخطاء والإلغاء
  14. 14الـ event loop والـ microtasks: Node بيعمل كل حاجة بـ thread واحد إزاي
  15. 15الـ Streams والـ Backpressure: ملفات أكبر من الـ memory
  16. 16الـ File System والـ paths: قراية وكتابة صح، ومن غير path traversal
  17. 17الـ Buffers والبيانات الـ binary: الـ bytes من جُوّه
  18. 18Crypto APIs والأسرار: random و hash و HMAC و AES-GCM
  19. 19الـ Worker Threads: شغل CPU تقيل من غير ما توقف الـ server
  20. 20الـ Errors على مستوى الـ process: operational و programmer و crash-only
  21. 21الـ Node test runner والـ debugging: tests من غير مكتبات
  22. 22HTTP من جُوّه: الـ methods والـ status codes والـ headers
  23. 23Express والـ Routing: الـ params والـ query والترتيب والـ Router
  24. 24Express 5: إيه اللي اتغيّر، وإزاي تنقل مشروع قديم
  25. 25الـ Middleware ودورة حياة الـ request جُوّه Express
  26. 26Validation للمدخلات بـ Zod: ما تصدّقش أي حاجة جاية من برة
  27. 27تصنيف الأخطاء و Problem Details: شكل واحد لكل الـ errors
  28. 28الـ CORS والـ Cookies: المتصفح بيحمي المستخدم إزاي
  29. 29رفع الملفات وحدود الحجم: multer من غير ثغرات
  30. 30الـ Realtime: Server-Sent Events و WebSockets
  31. 31OpenAPI والـ API Versioning: عقد مكتوب، وتغيير من غير ما تكسر حد
  32. 32PostgreSQL: الـ DDL وأنواع البيانات الصح لكل عمود
  33. 33الـ Constraints: PK و FK و UNIQUE و CHECK — الـ database بتحمي نفسها
  34. 34الـ Normalization والـ ERD: تقسّم البيانات صح من أول يوم
  35. 35الـ JOINs والتجميع: INNER و LEFT و GROUP BY و HAVING و window functions
  36. 36JSONB في PostgreSQL: إمتى تستخدمه، وإزاي تسأله وتعمله index
  37. 37الـ Indexes من جُوّه: B-tree و GIN و BRIN
  38. 38Partial و Covering indexes: indexes أصغر وأسرع
  39. 39الـ Pagination بالـ Keyset: ليه OFFSET بيبطّأ وبيكرر
  40. 40Full Text Search في Postgres: بحث بالكلمات، بالعربي والإنجليزي
  41. 41EXPLAIN ANALYZE والـ Planner: اقرا الـ plan وصلّح الـ query
  42. 42الـ Transactions بـ node-postgres: كله أو ولا حاجة
  43. 43الـ MVCC ومستويات الـ Isolation: transactions كتير في نفس الوقت
  44. 44الـ Locks والـ Deadlocks: مين مستني مين
  45. 45SKIP LOCKED و Job Leasing: Postgres كـ job queue
  46. 46Row Level Security والـ Multi-tenancy: كل عميل يشوف بياناته بس
  47. 47Migrations من غير downtime: expand و backfill و contract
  48. 48الـ Replication والـ Read Replicas: نسخ حية من الـ database
  49. 49الـ Connection Pooling و PgBouncer: connections أقل، requests أكتر
  50. 50الـ Partitioning والـ VACUUM والمراقبة: Postgres على المدى الطويل
  51. 51Redis وأنواع البيانات: strings و hashes و lists و sets و sorted sets
  52. 52Cache-aside والـ TTL: Redis قدام الـ database
  53. 53الـ Cache invalidation والـ Stampede: لما الـ key الشهير يموت
  54. 54Lua والـ Atomicity في Redis: كام أمر كأنهم أمر واحد
  55. 55الـ Rate Limiting في Redis: fixed window و sliding window و token bucket
  56. 56الـ Sessions في Redis: تسجيل دخول تقدر تلغيه في أي وقت
  57. 57Redis Streams والـ Consumer Groups: log بيتوزع على workers
  58. 58Pub/Sub و BullMQ: إشارات بين الـ instances، وطوابير شغل محترمة
  59. 59Redis لما يقع: الـ persistence (RDB و AOF) والـ replication
  60. 60Redis في الإنتاج: الـ ACLs والـ Cluster والمراقبة
  61. 61تخزين الـ Passwords بـ Argon2id: صح من أول مرة
  62. 62Session Fixation والـ Rotation: id جديد مع كل صلاحية جديدة
  63. 63الـ Cookie Flags والـ CSRF: المتصفح بيبعت الـ cookie، فلازم تتأكد مين اللي طلب
  64. 64الـ XSS والـ Content Security Policy: ما تخليش النص يتحوّل لـ code
  65. 65الـ OAuth و OpenID Connect و PKCE: login بـ Google من غير ما تشوف الـ password
  66. 66التأكد من الـ JWT صح: التوقيع والـ claims والـ scopes
  67. 67الـ BOLA و BFLA: الـ token السليم مش معناه إن الطلب مسموح
  68. 68الـ RBAC و ABAC والملكية: policy واحدة بدل ifs متفرقة
  69. 69الـ MFA والـ recovery: التاني factor اللي بجد
  70. 70الـ Passkeys و WebAuthn: login من غير password وضد الـ phishingانت هنا
  71. 71الـ Threat Modeling بـ STRIDE: فكّر زي المهاجم قبل ما تكتب code
  72. 72الـ SQL Injection والـ Parameterization: الـ data ما تبقاش code
  73. 73الـ SSRF والـ Egress: ما تخليش الـ server بتاعك يزور الشبكة الداخلية
  74. 74الـ Security Headers والـ TLS: كل response يقول للـ browser يحمي المستخدم إزاي
  75. 75توقيع الـ Webhooks والـ Replay: الـ webhook ده جاي فعلًا من Stripe؟
  76. 76تغيير الأسرار والـ HMAC: إزاي تغيّر مفتاح من غير ما كل حاجة تقع
  77. 77سلسلة التوريد والـ SBOM: إنت واثق في ألف package ما تعرفهمش؟
  78. 78الـ Audit والـ Privacy Logs: سجّل مين عمل إيه، من غير ما تسجّل الأسرار
  79. 79اختبار الأمان و OWASP ASVS: الأمن جُوّه الـ CI، مش audit آخر السنة
  80. 80الـ Prototype Pollution والـ Resource DoS: request واحد يخلّي الكل admin أو يوقّع الـ server
  81. 81الـ SLI والـ SLO والـ Error Budget: إمتى تصحّي الـ on-call وإمتى تسيبه نايم
  82. 82الـ Event Loop Delay والـ ELU: لما Node نفسه يتخنق
  83. 83الـ Worker Threads والـ CPU Profiling: الشغل التقيل بره الـ event loop، والوقت راح فين
  84. 84الـ Memory والـ GC والـ Leaks: الـ process اللي بيكبر لحد ما يقع
  85. 85الـ N+1 Queries والـ DataLoader: صفحة واحدة بمِيّتين query
  86. 86الـ HTTP Caching والـ Compression: أسرع request هو اللي ما بيوصلش
  87. 87الـ Load Testing والـ Soak Testing: الـ server بيستحمل قد إيه بجد
  88. 88الـ Concurrency Limits والـ Bulkheads: dependency بطيئة ما توقعش الـ app كله
  89. 89الـ Timeouts والـ Retries والـ Circuit Breakers: إزاي تتعامل مع dependency بطيئة أو واقعة
  90. 90OpenTelemetry والـ Distributed Tracing: الـ request راح فين وضاع وقته فين
  91. 91Docker Layers والـ Build Context: ليه الـ build بياخد دقيقة وفيه الـ .env بتاعك
  92. 92Multi-stage Builds و Non-root: image صغيرة ومن غير root
  93. 93Docker Compose والـ Networks: الـ services بتلاقي بعض إزاي
  94. 94Docker Volumes: الـ data بتتحفَظ فين
  95. 95Healthcheck و Restart و Resource Limits: running مش معناها شغّال
  96. 96BuildKit والـ Build Secrets: الـ token ما يدخلش الـ image
  97. 97Reverse Proxy و TLS: اللي واقف قدام الـ app
  98. 98Multi-arch Images والـ Native Modules: اشتغلت عندي
  99. 99CI/CD و Rollback و Canary: الـ deploy يبقى ممل
  100. 100Kubernetes من الأول: Pods و Deployments و Services و Probes
  101. 101Modular Monolith و DDD: حدود واضحة من غير network
  102. 102Transactional Outbox و Inbox: الـ event ما يضيعش وما يتنفذش مرتين
  103. 103Sagas: عملية واحدة على تلات services من غير transaction واحدة
  104. 104CQRS و Event Sourcing: الـ events هي الحقيقة
  105. 105الـ Queues والـ Brokers: BullMQ و RabbitMQ و Kafka و SQS
  106. 106Realtime على أكتر من instance: Redis pub/sub و presence و resume
  107. 107الـ Object Storage والـ Media: presigned URLs و uploads مباشرة
  108. 108التكامل مع الـ Email والـ Search: retries و webhooks و indexes
  109. 109GraphQL و gRPC في الإنتاج: contracts و DataLoader و limits و deadlines
  110. 110Kafka على أكتر من zone و region: الـ replication والـ ISR والـ acks والـ MirrorMaker والـ failover
  111. 111TypeScript و runtime boundaries: الـ types بتختفي، والـ schemas لأ
  112. 112ORM ولا SQL: query builders و repositories و migrations و transactions
  113. 113الـ Serverless من جُوّه: cold starts و freeze و timeouts و connections
  114. 114الـ Testing Pyramid: unit و integration و e2e على Postgres حقيقية
  115. 115Contract Testing و Property-Based Testing بـ fast-check
  116. 116الـ Payments: idempotency و webhooks و refunds و reconciliation
  117. 117الـ Timezones والـ Internationalization: UTC و DST والـ locales والـ plurals والفلوس
  118. 118الـ Privacy والـ Data Retention: consent و export و erasure و crypto shredding
  119. 119الـ ADRs والـ Feature Flags: القرارات المكتوبة والـ rollout من غير deploy
  120. 120Multi-region active-active: حل الـ conflicts بـ HLC و CRDTs
  121. 121Readiness و Liveness و Startup Probes: الـ pod جاهز ولا عايش؟
  122. 122Incident Runbooks: من الـ alert للـ postmortem