docs/development/concepts/secure-coding/README.md
This document provides secure coding development guidelines for developers working on OpenProject. The objective is to help identify and mitigate potential security vulnerabilities early in the development process. This document is based on the best practices following the Open Web Application Security Project (OWASP).
By following these guidelines, developers can contribute to OpenProject while ensuring the security of OpenProject and reduce the risk of vulnerabilities being released into production.
The following guidelines are a starting point for developers interesting in contributing in OpenProject to ensure they are developing secure code. We recommend to refer to the OWASP cheat sheets as well as the OWASP Top Ten for the most recent and detailed guidelines. The following sections are heavily inspired and cross-referencing the well-known recommendations from the the OWASP, each section providing links for further references to generic, Rails-centered as well as OpenProject-specific information when available.
By adhering to these secure coding development guidelines, contributors to OpenProject can help to significantly reduce the risk of adding potentially unsecure code. Regardless of these guidelines, be mindful when reviewing pull requests of features touching any of these guidelines, keep security in mind whenever you write new code for OpenProject to ensure we deliver a secure and trustworthy software.
The guidelines mentioned below are implemented by OpenProject currently when not specified differently.
Implement strong authentication mechanisms for any sensitive credentials to be used in OpenProject. Currently these credentials are one of:
Risks and Impacts
Guidelines
<a id="usage-at-openproject"></a>
Usage at OpenProject
OpenProject uses industry standard authentication mechanisms that follow the best practices and are the de-facto norm for many organizations:
<a id="usage-recommendations"></a>
OpenProject recommends these authentication mechanisms:
All connections to and from OpenProject should be secured through TLS/SSL transport encryption. OpenProject assumes connections are secured through TLS/SSL by default in all production systems. Note that OpenProject does not provide TLS/SSL termination itself for Docker-based installations. The customer's IT department needs to configure and maintain the TLS certificates at the load balancer or proxying server before connections reach the application server.
For any external connection (Database, LDAP, etc.), OpenProject uses openssl library for the host or container's openssl certificate store. Use your distribution's mechanisms to add verified certificate or certificate chains. For more information, see the Ruby OpenSSL X509 Store documentation.
For smaller to medium organizations with no centralized authentication mechanism, use the internal username / password authentication mechanism for secure storing of your user's credentials using BCrypt salted cryptographic hash function.
For organizations with a centralized and accessible LDAP server, OpenProject provides LDAP userbind authentication to forward the authentication request to your LDAP server. Use TLS or LDAPS encrypted connections to the LDAP server to ensure transport level security. Optionally, synchronize roles and permissions using the LDAP Group sync functionality.
If your organization operates a central authentication services, it is very likely it supports one of the standard remote authentication mechanisms for single sign-on, such as OpenID connect, SAML, or Kerberos. Use these mechanisms to ensure a standardized and secure authentication of users without requiring the storage of any credentials at OpenProject while providing a high level of usability due to centralized logins.
References
As OpenProject is a web application, the web session is the central mechanism of authentication for users using the application with their browser. A secure session cookie is used to identify a user's active session.
Risks and Impacts
Session Hijacking: Attackers may steal or manipulate active user session identifiers, gaining unauthorized access to user accounts or sensitive areas of the application. Resulting consequences are unauthorized access, data exposure, and potential misuse of user accounts.
Session Fixation: Vulnerabilities that allow session fixation attacks can enable attackers to set a user's session ID and take control of their session. Resulting consequences are unauthorized access, data manipulation, and session theft.
Improper Session Timeout: Inadequate session timeout settings can lead to prolonged active sessions, increasing the window and surface of opportunity for attackers. Resulting consequences are exposure to session-related attacks and unauthorized access.
Insecure Session Storage: Storing session data insecurely (e.g., in client-side storage or without proper care) can expose it to theft or tampering. Potential impacts are unauthorized data access or manipulation, data breaches, and privacy violations.
Insufficient Session Revocation: Lack of proper mechanisms to revoke or terminate user sessions can result in prolonged access for users who should no longer have it. Potential impacts are unauthorized access to protected resources and data.
Cross-Site Scripting (XSS) and Session Theft: If an application is vulnerable to XSS attacks, attackers can steal session identifiers and impersonate users.
Lack of Session Regeneration: Failure to regenerate session identifiers upon login or privilege changes can expose users to session fixation attacks.
Session Data Tampering: Inadequate session data validation and protection can lead to attackers modifying session attributes to gain unauthorized privileges.
Weak Session Tokens: Weak or predictable session token generation can make it easier for attackers to guess or brute-force session identifiers.
Guidelines
secure and httponly, as well as providing the appropriate SameSite and expiration flags according to the instance's configuration.References
At its core, permissions in OpenProject are the central key to determine who can access which projects and modules of an instance, as well as what actions they can perform on these pages. OpenProject application uses a Role-based access control (RBAC) approach to grant individual users permissions to projects. The risks associated with security vulnerabilities in the authorization code can have serious implications for the security.
Risks and Impact
Guidelines
References
OpenProject is a form-driven application, meaning that users input a lot of data into the system to use it. Proper validation and encoding of user input is crucial to ensure data can be processed in a responsible way.
Risks and Impacts
Guidelines
References
As OpenProject may handle and distribute sensitive user data, attack vectors such as malicious user input as specified in the previous section pose a threat to the integrity, confidentiality, and availability of data. In the following, we will evaluate different risks and guidelines on the protection against viruses and other malware during operation of an OpenProject instance.
Risks and impacts
Guidelines
Inconsiderate use of error handling, logging, and monitoring mechanisms of a web frameworks can lead to the following risks and impacts.
Risks and Impacts
Guidelines
Usage at OpenProject
References
OpenProject includes a number of external dependencies both in Ruby as well as in the JavaScript ecosystem. Regardless of the selection of these dependencies, maintaining and keeping the dependencies up-to-date is a critical part of the security of the application. We have seen a lot of attacks surface in the past years originating from either outdated or manipulated dependencies.
Risks
Guidelines
npm outdated, bundle outdated or npm-check-updates to ensure you stay on top of new versions and see if breaking changes occurred.package-lock.json and Gemfile.lock to pin exact version for a released version of OpenProject, ensuring that all environments use the same versions.References
Packaging and containerization are critical artifacts in the delivery pipeline of OpenProject. They encapsulate the application and its environment, ensuring consistent operation across different systems and infrastructures. These artifacts need to provide a secure and stable default for maintaining and upgrading OpenProject.
Properly managed packaging and containerization pipelines ensure smooth installations, upgrades, and scaling, enhancing the deployment process and - as a result - the overall user experience. This section highlights risks connected to improper containerization or packaging as well as our main objectives and best practices to provide a secure, efficient, and reliable software delivery process.
OpenProject provides several installation mechanisms:
Packaged installations using the distribution's package manager for dependency control
Slim and all-in-one docker images for manual operation with docker
OpenProject helm chart , as a "package" for kubernetes clusters
Risks and Impact
Guidelines
ruby-${version}-${debianversion} image as its base.dev containers and packages for every change to the core application.