CS 50 Introduction to Cybersecurity: Software Security

Jun 1, 2024

CS 50 Introduction to Cybersecurity: Software Security

Introduction & Phishing

  • Lecturer: David Malan
  • Topic: Securing software (software you use and write)
  • Example: Phishing (attacking and noticing attacks)
  • HTML Basics:
    • Hypertext Markup Language, simple example, tags (open tag/start tag <p>, closing tag/end tag </p>)
    • Tags used: <p>, <script>, <a>
  • Threats:
    • Creating malicious links misrepresenting actual links
    • Checking URLs by hovering (not clicking immediately)
    • Example of spoof sites (Yale vs. fake Harvard)

Cross Site Scripting (XSS)

  • Concept: Tricking websites into executing your scripts (JavaScript) using their inputs
  • Examples of XSS:
    • Example of using <script> tags inside user inputs
    • Impact (inserting scripts like alert('attack'))
  • Threats and Protections:
    • Reflected attacks (user input is reflected back and executed in another context)
    • Stored attacks (data input store in database and executed when retrieved)
    • Mitigating XSS attacks using character escapes (e.g., &lt; for <)
    • HTTP Headers (Content-Security-Policy) to restrict execution of inline scripts and styles

Code Injection Attacks

  • SQL Injection:

    • Example: select * from users where username = 'username' and password = 'password'
    • Example attack input: '; DELETE FROM users; --
    • Effect of a successful SQL injection (deleting data, retrieving wrong data)
    • Defense: Prepared Statements (using placeholders to safely include user input)
  • Command Injection:

    • Using functions like system() and eval() can be dangerous
    • Best Practice: Avoiding direct execution of user inputs as system commands

Cross Site Request Forgery (CSRF)

  • Concept: Tricking users into performing actions they did not intend
  • Examples of GET and POST requests:
    • GET request example: URL contains all necessary information
    • POST request example: using forms (<form> with method="post")
  • Defense:
    • Using CSRF tokens to validate authenticity of requests
    • Avoiding GET for state-changing operations

Secure Software Practices

  • Open Source vs. Closed Source:
    • Open Source: Readable by all, potential for better scrutiny but also for attacks
    • Closed Source: Internal only, harder to attack but less community verification
  • Trusted Sources:
    • Using App Stores (i.e., Apple App Store, Google Play Store)
    • Ensuring downloaded apps are from legitimate sources
  • Digital Signatures:
    • Verifying software with digital signatures (using cryptographic techniques)

Package Managers & Bug Bounties

  • Package Managers:
    • Examples: pip (Python), gem (Ruby), npm (Node.js)
    • Ensuring packages are signed and verified
  • Bug Bounties:
    • Encouragement of ethical hacking to discover and report bugs for rewards

Final Considerations

  • Keeping Track of Vulnerabilities:
    • Common Vulnerabilities and Exposures (CVE)
    • Common Vulnerability Scoring System (CVSS)
    • Exploit Prediction Scoring System (EPSS)
    • Known Exploited Vulnerability Catalog (KEV)