انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-023-L05

أمان الرفع

  • الدرس 5 من 6
  • Junior
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

name the main upload risks.

الموضوعات المخطط لها

  • Path traversal: a name like ../../etc/passwd escapes the folder. Prevent it by never using the client name in a path; if you must resolve a path, normalize() it and check it stays inside the base directory.
  • Oversized files: exhaust disk or memory. Enforce limits.
  • Content sniffing: a browser may guess a type and run a file as script. Send the right Content-Type, and X-Content-Type-Options: nosniff.
  • Trusting the declared type: verify signatures for important types.
  • Serve uploads only through your controller, with access checks.
تفاصيل المخطط المبدئي

عرض عملي

java
Path target = base.resolve(storedName).normalize();
if (!target.startsWith(base)) throw new IllegalArgumentException("Bad path");

اختبر فهمك

Which input should never be part of a path?

أظهر الإجابة

The client's filename.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.