Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Security in open source projects

jmortegac
August 12, 2019

Security in open source projects

Security in open source projects

jmortegac

August 12, 2019
Tweet

More Decks by jmortegac

Other Decks in Technology

Transcript

  1. FROSCON 2019 SECURITY TRACK
    Security in open source projects
    José Manuel Ortega @jmortegac

    View Slide

  2. @jmortegac
    jmortega.github.io
    about.me/jmortegac

    View Slide

  3. CONFERENCES http://jmortega.github.io/

    View Slide

  4. CONFERENCES

    View Slide

  5. AGENDA

    View Slide

  6. AGENDA

    View Slide

  7. AGENDA
    ● Security in open source projects
    ● Vulnerabilities in dependencies
    ● Detecting vulnerabilities in code base
    ● Improving security in open source

    View Slide

  8. AGENDA
    Functionality vs security
    ● Security is always a secondary concern
    ● Primary goal of software is to provide some
    functionality or services
    ● Managing associated risks to software we
    are developing is a derived/ secondary
    concern

    View Slide

  9. AGENDA
    Functionality vs security
    Functionality is about what
    software should do,
    security is (also) about what it
    should not do

    View Slide

  10. AGENDA
    Functionality vs security

    View Slide

  11. Coding Flaws
    ● flaws that can be understood looking at the program
    itself.
    ○ confusing two program variables and errors in the
    program logic
    ● problems in the interaction with the underlying platform
    or other systems and services
    ○ buffer overflows in C(++) code
    ○ integer overflows in most programming languages
    ○ SQL injection, XSS, CSRF in web-applications

    View Slide

  12. ● Buffer overflow
    ● Use-after-free
    ● Stack corruption
    Memory vulnerabilities

    View Slide

  13. Buffer overflow
    // A C program to demonstrate buffer overflow
    #include
    #include
    #include
    int main(int argc, char *argv[])
    {
    // Reserve 5 byte of buffer plus the terminating NULL.
    // should allocate 8 bytes = 2 double words,
    // To overflow, need more than 8 bytes...
    char buffer[5];
    // copy the user input to mybuffer, without any
    // bound checking a secure version is srtcpy_s()
    strcpy(buffer, argv[1]);
    printf("buffer content= %s\n", buffer);
    return 0;
    }

    View Slide

  14. Buffer overflow

    View Slide

  15. Know your dependencies
    ● What open source components you are
    using?
    ● What versions you are currently running, and
    where?
    ● How these components can be updated,
    where do you get the update, what do you
    need to do to install them?

    View Slide

  16. AGENDA
    PACKAGE REPOSITORIES

    View Slide

  17. Third-party libraries

    View Slide

  18. Third-party libraries
    Reusable Components = Reusable Vulnerabilities
    ● Attackers are increasingly targeting popular
    libraries and 3rd party components
    ● Up to 90% of the attack surface of an application
    may be due to 3rd party code

    View Slide

  19. AGENDA
    DEPENDENCIES

    View Slide

  20. AGENDA
    DEPENDENCIES

    View Slide

  21. AGENDA
    OWASP DEPENDENCY-CHECK

    View Slide

  22. AGENDA
    DEPENDENCY-CHECK

    View Slide

  23. AGENDA
    SNYK

    View Slide

  24. AGENDA
    SNYK

    View Slide

  25. Services

    View Slide

  26. Services

    View Slide

  27. Services

    View Slide

  28. Services

    View Slide

  29. Package vulnerabilities

    View Slide

  30. NPM Package vulnerabilities

    View Slide

  31. NPM Package vulnerabilities

    View Slide

  32. SQL inyection vulnerabilities

    View Slide

  33. Detecting security vulnerabilities

    View Slide

  34. Malicious Python packages

    View Slide

  35. SAST vs DAST
    How you can detect security vulnerabilities?

    View Slide

  36. STATIC

    View Slide

  37. FIND SECURITY BUGS

    View Slide

  38. SONARQUBE

    View Slide

  39. SONARQUBE

    View Slide

  40. SONARQUBE

    View Slide

  41. Static Application Security Testing (SAST)

    View Slide

  42. Static Application Security Testing (SAST)

    View Slide

  43. Security Dashboard GitLab

    View Slide

  44. NodeJsScan

    View Slide

  45. NodeJsScan

    View Slide

  46. NodeJsScan

    View Slide

  47. Bandit

    View Slide

  48. Bandit

    View Slide

  49. Bandit
    SELECT %s FROM derp;” % var
    “SELECT thing FROM ” + tab
    “SELECT ” + val + ” FROM ” + tab + …
    “SELECT {} FROM derp;”.format(var)

    View Slide

  50. Dynamic Application Security Testing (DAST)

    View Slide

  51. DYNAMIC

    View Slide

  52. AGENDA
    OWASP ZAP

    View Slide

  53. Dynamic Application Security Testing (DAST)

    View Slide

  54. AGENDA
    SQL INYECTION

    View Slide

  55. AGENDA
    SQL INYECTION

    View Slide

  56. AGENDA
    SQL INYECTION

    View Slide

  57. Open Source Security
    What can we do to improve the security of Open
    Source Software?
    ● We can do all the same things as we do when
    building commercial software
    ● The big difference is that we have to do it
    collaboratively.

    View Slide

  58. Propietary vs OS vulnerabilities

    View Slide

  59. Open Source Security
    OSS is not more or less secure, but it is different
    • Typically there are many more people contributing
    • Sometimes there is a culture of “code is more
    important than specification”
    • There may be less market pressure to put security
    first

    View Slide

  60. Open Source Security
    Security is a process, not a
    product

    View Slide

  61. Software Development Life Cycle

    View Slide

  62. Software Development Life Cycle

    View Slide

  63. Core Infrastructure Initiative

    View Slide

  64. Core Infrastructure Initiative
    https://bestpractices.coreinfrastructure.org/en/projects/1/0#security

    View Slide

  65. Core Infrastructure Initiative
    https://bestpractices.coreinfrastructure.org/en/projects/1/0#security

    View Slide

  66. Core Infrastructure Initiative
    https://github.com/coreinfrastructure/best-practices-badge/blob/master
    /doc/security.md

    View Slide

  67. Open Source Security

    View Slide

  68. AGENDA
    GITHUB ALERTS

    View Slide

  69. Secrets searching on github
    ○ Credentials(Cryptographic keys,
    BBDD credentials, API tokens
    (AWS), SSH keys)
    ○ Infrastructure(Services
    configuration (DHCP, SMTP, etc),IPs
    and internal URLs)
    ○ Code(Commits, History, Comments,
    Dependencies, Vulnerabilities)

    View Slide

  70. Secrets searching on github
    ● Private keys (id_rsa, id_dsa, *.pfx)
    ● History files (.bash_history and similar) - these often
    have passwords which were mistyped
    ● Log files (/var/log/*) - again, they often have details
    you might forget to look for in .htaccess, .htpasswd -
    Apache directory specific configuration files
    ● web.config - IIS directory specific config file
    ● wp-config.php - Wordpress config

    View Slide

  71. Secrets searching on github

    View Slide

  72. Secrets searching on github

    View Slide

  73. Secrets searching on github

    View Slide

  74. Remove sensitive data

    View Slide

  75. Remove sensitive data

    View Slide

  76. CONCLUSIONS
    ● Open source maintainers
    ○ Practice secure code review
    ○ Regularly audit your code base for
    vulnerabilities
    ○ Define a process for communication of
    responsible disclosures

    View Slide

  77. CONCLUSIONS
    ● Open source developers
    ○ Follow responsible disclosure policies if you
    are reporting a security vulnerability
    ○ Subscribe to the security communication
    channels of your open source dependencies

    View Slide

  78. CONCLUSIONS
    ● Security is a very important aspect of
    software development.
    ● Measures can be taken to integrate it in
    the Software Development Life Cycle.
    ● It is possible to effectively integrate
    security into agile development as well

    View Slide

  79. CONCLUSIONS

    View Slide