Secure Coding Practices (OWASP)
Secure Coding Practices (OWASP)
CODING
PRACTICES
CHECKLIST
(OWASP)
INPUT VALIDATION
OUTPUT ENCODING
SESSION MANAGEMENT
ACCESS CONTROL
CRYPTOGRAPHIC PRACTICES
DATA PROTECTION
COMMUNICATION SECURITY
SYSTEM CONFIGURATION
DATABASE SECURITY
FILE MANAGEMENT
MEMORY MANAGEMENT
Ensure servers, frameworks, and components are running the latest approved
versions.
Apply all relevant patches to the versions in use.
Restrict web server, process, and service accounts to least privilege.
Turn off directory listings to prevent unauthorized browsing.
Disable unnecessary HTTP methods and ensure supported methods (e.g.,
GET or POST) are handled securely and consistently across application
pages.
Configure all supported HTTP versions similarly and document any
differences.
Remove unnecessary information from HTTP response headers (e.g., OS,
web-server version, application frameworks).
Prevent directory structure exposure in the robots.txt file by isolating
directories not intended for public indexing.
On exceptions, ensure the application and server fail securely.
Remove unnecessary functionality, test code, or files not intended for
production before deployment.
Isolate development environments from production networks, restricting
access to authorized personnel.
Implement a software change control system to manage and log code
changes in development and production environments.
Ensure the security configuration store is human-readable to support
auditing.
Establish an asset management system to track and register all system
components and software.
DATABASE SECURITY
Do not pass user supplied data directly to any dynamic include function
Require authentication before allowing a file to be uploaded
Limit the type of files that can be uploaded to only those types that are
needed for business purposes
Validate uploaded files are the expected type by checking file headers rather
than by file extension
Do not save files in the same web context as the application
Prevent or restrict the uploading of any file that may be interpreted by the
web server.
Turn off execution privileges on file upload directories
Implement safe uploading in UNIX by mounting the targeted file directory
as a logical drive using the associated path or the chrooted environment
When referencing existing files, use an allow-list of allowed file names and
types
Do not pass user supplied data into a dynamic redirect
Do not pass directory or file paths, use index values mapped to pre-defined
list of paths
Never send the absolute file path to the client
Ensure application files and resources are read-only
Scan user uploaded files for viruses and malware
MEMORY MANAGEMENT
Use tested and approved managed code instead of creating unmanaged code
for common tasks.
Leverage task-specific built-in APIs for OS interactions; avoid issuing direct
OS commands or using application-initiated command shells.
Review secondary applications, third-party code, and libraries for business
necessity and safe functionality.
Use checksums or hashes to verify the integrity of interpreted code, libraries,
executables, and configuration files.
Implement secure updating mechanisms using encrypted channels.
Use locking mechanisms or synchronization to prevent race conditions.
Protect shared variables and resources from inappropriate concurrent access.
Explicitly initialize all variables during declaration or before first use.
When elevated privileges are necessary, raise them as late as possible and
drop them immediately after use.
Avoid calculation errors by understanding the underlying representation of
your programming language.
Do not pass user-supplied data to dynamic execution functions.
Restrict users from generating or altering code.
Validate that all secondary applications, third-party code, and libraries are
necessary and safe.