סילבוס סדנאת פיתוח מאובטח SSDLC

מחזור חיים מאובטח לפיתוח תוכנה (SSDLC) עם קידוד מעשי

כותרת הסדנה: Secure Software Development Lifecycle (SSDLC) with Hands-On Coding

משך: שעתיים

קהל יעד: מפתחי תוכנה, מהנדסי אבטחה, בודקי QA, אנשי IT

מטרות למידה:

בסיום הסדנה, המשתתפים:

  • יבינו את החשיבות של שילוב אבטחה בכל שלב של ה-SDLC.
  • ילמדו כיצד לזהות ולהפחית סיכוני אבטחה במהלך פיתוח תוכנה.
  • יתנסו בטכניקות קידוד מאובטח כדי למנוע פגיעויות נפוצות.
  • יקבלו ניסיון מעשי עם כלי בדיקות אבטחה ומידול איומים.

סדר יום של הסדנה:

1. מבוא ל-SSDLC (30 דקות)

מודול זה יכסה את עקרונות היסוד של SSDLC ויכיר מושגי אבטחה הרלוונטיים לפיתוח תוכנה.

מהו SDLC? סקירה מהירה של שלבי SDLC המסורתיים: דרישות, עיצוב, פיתוח, בדיקות, פריסה ותחזוקה.

מדוע פיתוח תוכנה מאובטח? דיון על החשיבות של אבטחת יישומים וההשלכות האפשריות של פרצות אבטחה. סקירת מקרי מבחן מהעולם האמיתי כגון פרצת MOVEit והפרצה ב-T-Mobile.

מבוא ל-SSDLC: כיצד משולבת אבטחה בכל שלב של SDLC.

עקרונות אבטחה: כיסוי עקרונות מרכזיים כגון CIA Triad (סודיות, שלמות, זמינות), עקרון המינימום הרשאות, והגנה בשכבות (Defense in Depth).

פעילות:

דיון קבוצתי: המשתתפים ינתחו פרצות אבטחה אחרונות ויזהו את שלב ה-SDLC שבו הוכנסו הפגיעויות.

2. פירוט של SSDLC לפי שלבים עם דוגמאות קוד (שעה)

העמקה כיצד ליישם פרקטיקות אבטחה במהלך כל שלב של SDLC, כולל תרגילי קידוד מעשיים.

1. איסוף דרישות

דרישות אבטחה: הבנה כיצד להגדיר דרישות אבטחה לצד דרישות פונקציונליות.

כלים: מבוא לשימוש ב-Use Cases, Misuse Cases, ורשימות דרישות אבטחה.

דוגמה:

הגדרת דרישות אבטחה לאימות משתמש:

  • אימות רב-גורמי (MFA).
  • הצפנת סיסמאות באמצעות bcrypt עם Cost Factor של 12.
  • חסימה לאחר 5 ניסיונות כניסה כושלים.

2. עיצוב מאובטח

מודל איומים: כיצד לזהות איומי אבטחה בשלב העיצוב.

עקרונות: עיצוב מאובטח, הגנה בשכבות (Defense in Depth), ואימות קלט.

כלים: Microsoft Threat Modeling Tool, OWASP Threat Dragon.

דוגמה:

איום של העלאת קבצים לא מוגבלת וכיצד למנוע זאת על ידי הגבלת סוגי הקבצים המותרים (לדוגמה, .jpg, .png, .pdf) וסריקת תוכנות זדוניות.

3. פיתוח מאובטח (עם דוגמאות קוד)

פרקטיקות קידוד מאובטח: מבוא ל-OWASP Top 10 והפרקטיקות המומלצות למניעתן.

דוגמאות:

מניעת SQL Injection

קוד לא מאובטח: פגיעות ל-SQL Injection:

cursor.execute("SELECT * FROM users WHERE username = '" + username + "' AND password = '" + password + "'")

קוד מאובטח: שימוש בשאילתות פרמטריות:

cursor.execute("SELECT * FROM users WHERE username = %s AND password = %s", (username, password))

מניעת Cross-Site Scripting (XSS)

קוד לא מאובטח, פגיע ל-XSS:

<div>Hello, <?php echo $_GET['name']; ?></div>

קוד מאובטח: המרת פלט למניעת XSS:

<div>Hello, <?php echo htmlspecialchars($_GET['name'], ENT_QUOTES, 'UTF-8'); ?></div>

סקירת קוד: הפרקטיקות המומלצות לסקירות עמיתים, ניתוח קוד סטטי באמצעות SonarQube.

4. בדיקות אבטחה

שיטות בדיקות אבטחה: SAST (Static), DAST (Dynamic), IAST (Interactive).

דוגמה:

Running SonarQube for a static analysis of code:

sonar-scanner -Dsonar.projectKey=myproject -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000 -Dsonar.login=your_token

בדיקות חדירה: שימוש ב-OWASP ZAP למציאת פגיעויות נפוצות כמו XSS או CSRF.

5. פריסה וניטור

פריסה מאובטחת: אכיפת עקרון ההרשאות המינימליות עבור פריסות, חיזוק סביבות והגנה על מפתחות API.

ניטור: הגדרת לוגים עבור פעילויות חשודות באמצעות כלים כמו Graylog או Splunk.

דוגמה:

Logging failed login attempts in Python:

import logging
logging.basicConfig(filename=’security.log’, level=logging.WARNING)
logging.warning(‘Failed login attempt for user: %s’, username)

6. תחזוקה

אבטחה מתמשכת: תיקונים רציפים, עדכון ספריות וניהול פגיעויות.

כלים: אוטומציה לזיהוי פגיעויות באמצעות Dependabot.

3. תרגול מעשי: תרגיל דוגמנות איומים (45 דקות)

משתתפים יתרגלו זיהוי סיכוני אבטחה על ידי יצירת מודלי איומים למערכת נתונה.

תרחיש: המשתתפים יקבלו דיאגרמת מערכת של פלטפורמת מסחר אלקטרוני ויזהו איומים פוטנציאליים על אבטחה (לדוגמה, חשיפת נתונים, אימות חלש).

כלים: שימוש ב-Microsoft Threat Modeling Tool או OWASP Threat Dragon ליצירת מודלי איומים.

פעילות:

עבודת צוות ליצירת מודלי איומים והצגת ממצאים עם הצעות למיתון.

4. סדנת תכנות מאובטח (עם דוגמאות קוד נוספות) (45 דקות)

קטע זה מתמקד בתרגול תכנות מאובטח וזיהוי פגיעויות בדוגמאות קוד מהעולם האמיתי.

פגיעויות נפוצות: דיון בפגיעויות כמו buffer overflows, התקפות הזרקה, ו-XSS.

OWASP Top 10: סקירה של פגיעויות נפוצות וטכניקות למיתון.

דוגמאות:

Buffer Overflow (C language)

char buffer[10];
strcpy(buffer, userInput); // No bounds checking

קוד מאובטח: שימוש בפונקציות מחרוזת בטוחות יותר:

strncpy(buffer, userInput, sizeof(buffer) - 1);
buffer[sizeof(buffer) - 1] = ‘\0’; // Null-terminate to avoid overflow

Cross-Site Request Forgery (CSRF)

הגנה מפני CSRF באמצעות טוקן:

<form method="POST" action="/submit">
  <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
  <input type="text" name="data">
  <button type="submit">Submit</button>
</form>

פעילות:

משתתפים יקבלו קטעי קוד לא מאובטחים (SQL Injection, XSS) ויצטרכו לזהות ולתקן את בעיות האבטחה.

5. בדיקות אבטחה (עם תרגול מעשי) (45 דקות)

מודול זה מתמקד באוטומציה של בדיקות אבטחה והרצת בדיקות בזמן אמת על יישומים.

סקירה כללית: היכרות עם SAST, DAST, ו-IAST.

דוגמה:

Running OWASP ZAP for testing SQL injection vulnerabilities:

zap.sh -daemon -config api.key=your_api_key -port 8080

פעילות:

משתתפים ישתמשו ב-OWASP ZAP או Burp Suite לבדיקת פגיעויות ביישומי אינטרנט.

6. שילוב DevSecOps (30 דקות)

למדו כיצד לשלב בדיקות אבטחה בצנרת ה-DevOps כדי להבטיח שהאבטחה היא רציפה.

מהו DevSecOps? שילוב של אבטחה בתוך צנרת ה-CI/CD.

אוטומציה: אוטומציה של בדיקות אבטחה, ניתוח קוד וסריקות פגיעות.

ניטור: ניטור אבטחה בזמן אמת באמצעות כלים כמו ELK Stack או Datadog.

פעילות:

משתתפים יתכננו צנרת DevSecOps וישלבו כלים לאוטומציה של בדיקות אבטחה וניטור.

7. סיכום ושאלות (15 דקות)

סיכום: סקירה של שלבי SSDLC, שיטות קידוד מאובטח, וטכניקות בדיקות אבטחה.

שאלות פתוחות: אפשרות למשתתפים לשאול שאלות ולדון באתגרים נוספים באבטחה.

Secure Software Development Lifecycle (SSDLC) with Hands-On Coding

Workshop Title: Secure Software Development Lifecycle (SSDLC) with Hands-On Coding

Duration: 2 Hours
Audience: Software developers, security engineers, QA testers, IT professionals

Learning Objectives:

By the end of the workshop, participants will:

  • Understand the importance of incorporating security in every phase of the SDLC.
  • Learn how to identify and mitigate security risks during software development.
  • Practice secure coding techniques to prevent common vulnerabilities.
  • Gain hands-on experience with security testing tools and threat modeling.

Workshop Agenda:

1. Introduction to SSDLC (30 minutes)

This module will cover the fundamental principles of SSDLC and introduce security concepts that apply to software development.

  • What is SDLC?: A quick review of the traditional SDLC phases: Requirements, Design, Development, Testing, Deployment, and Maintenance.
  • Why Secure Software Development?: Discuss the importance of securing applications and the potential consequences of security breaches. Real-world case studies such as the MOVEit breach and T-Mobile data breach will be reviewed to illustrate these points.
  • Introduction to SSDLC: How security is incorporated into each phase of the SDLC.
  • Security Principles: Cover key principles such as the CIA Triad (Confidentiality, Integrity, Availability), Principle of Least Privilege, and Defense in Depth.

Activity:

  • Group Discussion: Participants will discuss recent security breaches, identifying the SDLC phase where security vulnerabilities were introduced.

2. Phase-by-Phase Breakdown of SSDLC with Code Examples (1 hour)

A deep dive into how to apply security practices during each phase of the SDLC, including hands-on coding exercises.

1. Requirements Gathering
  • Security Requirements: Understand how to define security requirements alongside functional requirements.
  • Tools: Introduction to use cases, misuse cases, and security requirement checklists.

Example:

  • Define security requirements for user authentication:
    • Multi-factor Authentication (MFA).
    • Password hashing using bcrypt with a cost factor of 12.
    • Lockout after 5 failed login attempts.
2. Secure Design
  • Threat Modeling: How to identify security threats in the design phase.
  • Principles: Secure by design, defense in depth, and input validation.
  • Tools: Microsoft Threat Modeling Tool, OWASP Threat Dragon.

Example:

  • Unrestricted File Upload threat and how to mitigate it by allowing only specific file types (e.g., .jpg, .png, .pdf) and scanning for malware.
3. Secure Development (with Code Examples)
  • Secure Coding Practices: Introduction to OWASP Top 10 vulnerabilities and best practices for avoiding them.

Examples:

  1. Preventing SQL Injection
    Insecure Code: Vulnerable to SQL Injection:
    cursor.execute(“SELECT * FROM users WHERE username = ‘” + username + “‘ AND password = ‘” + password + “‘”)
    Secure Code: Using parameterized queries:
    cursor.execute(“SELECT * FROM users WHERE username = %s AND password = %s”, (username, password))
  2. Preventing Cross-Site Scripting (XSS)
    Insecure Code: Vulnerable to XSS:
    <div>Hello, <?php echo $_GET[‘name’]; ?></div>
    Secure Code: Escape output to prevent XSS:
    <div>Hello, <?php echo htmlspecialchars($_GET[‘name’], ENT_QUOTES, ‘UTF-8’); ?></div>
  • Code Review: Best practices for peer reviews, static code analysis using SonarQube.
4. Secure Testing
  • Security Testing Techniques: SAST (Static), DAST (Dynamic), IAST (Interactive).

Example:

  • Running SonarQube for a static analysis of code: sonar-scanner -Dsonar.projectKey=myproject -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000 -Dsonar.login=your_token
  • Penetration Testing: Using OWASP ZAP to find common vulnerabilities such as XSS or CSRF.
5. Deployment & Monitoring
  • Secure Deployment: Enforce least privilege for deployments, harden environments, and secure API keys.
  • Monitoring: Set up logging for suspicious activities using tools like Graylog or Splunk.

Example:

  • Logging failed login attempts in Python: import logging
    logging.basicConfig(filename=’security.log’, level=logging.WARNING)
    logging.warning(‘Failed login attempt for user: %s’, username)
6. Maintenance
  • Ongoing Security: Continuous patching, updating libraries, and vulnerability management.
  • Tools: Automating vulnerability detection using Dependabot.

3. Hands-On: Threat Modeling Exercise (45 minutes)

Participants will practice identifying security risks by creating threat models for a given system.

  • Scenario: Participants receive a system diagram of an e-commerce platform and identify potential security threats (e.g., data exposure, weak authentication).
  • Tools: Use Microsoft Threat Modeling Tool or OWASP Threat Dragon to build threat models.

Activity:

  • Group work to create threat models and present findings with suggested mitigations.

4. Secure Coding Practices Workshop (with More Code Examples) (45 minutes)

This section focuses on practicing secure coding and identifying vulnerabilities in real-world code examples.

  • Common Vulnerabilities: Discuss vulnerabilities like buffer overflows, injection attacks, and XSS.
  • OWASP Top 10: Review common vulnerabilities and mitigation techniques.

Examples:

  1. Buffer Overflow (C language)
    Insecure Code: Vulnerable to buffer overflow:
    char buffer[10];
    strcpy(buffer, userInput); // No bounds checking
    Secure Code: Use safer string functions:
    strncpy(buffer, userInput, sizeof(buffer) – 1);
    buffer[sizeof(buffer) – 1] = ‘\0’; // Null-terminate to avoid overflow
  2. Cross-Site Request Forgery (CSRF)
    Secure form with CSRF token:
    <form method=”POST” action=”/submit”> <input type=”hidden” name=”csrf_token” value=”{{ csrf_token }}”> <input type=”text” name=”data”> <button type=”submit”>Submit</button> </form>

Activity:

  • Participants are given insecure code snippets (SQL injection, XSS) and tasked with identifying and correcting the security issues.

5. Security Testing (with Hands-On) (45 minutes)

This module focuses on automating security testing and running real-time tests on applications.

  • Overview: Introduction to SAST, DAST, and IAST.
  • Tool Demo: Using OWASP ZAP for dynamic web application testing.

Example:

  • Running OWASP ZAP for testing SQL injection vulnerabilities: zap.sh -daemon -config api.key=your_api_key -port 8080

Activity:

  • Participants use OWASP ZAP or Burp Suite to test a demo web app for vulnerabilities.

6. Integrating DevSecOps (30 minutes)

Learn how to integrate security testing into a DevOps pipeline to ensure security is continuous.

  • What is DevSecOps?: Combining security into the CI/CD pipeline.
  • Automation: Automating security tests, code analysis, and vulnerability scans.
  • Monitoring: Real-time security monitoring using tools like ELK Stack or Datadog.

Activity:

  • Participants will design a DevSecOps pipeline and integrate security tools for automated testing and monitoring.

7. Wrap-Up and Q&A (15 minutes)

  • Recap: Review of SSDLC phases, secure coding practices, and security testing techniques.
  • Open Q&A: Allow participants to ask questions and discuss additional security challenges.

Materials & Tools Needed:

  • Demo environment with insecure web applications (e.g., OWASP Juice Shop).
  • Tools: OWASP ZAP, Burp Suite, SonarQube, Dependabot for vulnerability management.

Key Takeaways:

  • Security must be integrated into every phase of the SDLC.
  • Secure coding practices reduce vulnerabilities.
  • Automated testing and monitoring tools help maintain application security.

 

תגובות

האימייל לא יוצג באתר. שדות החובה מסומנים *