-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Security checklist: DB "operations needed" #2356
Open
adriendupuis
wants to merge
9
commits into
master
Choose a base branch
from
checklist-db
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dea188f
Security checklist: File system permissions
glye 20063ff
security_checklist.md: Restricted DB user w/ example
adriendupuis 0533601
Apply suggestions from code review
adriendupuis 58012d2
Review feedback
glye b3d0189
Update docs/infrastructure_and_maintenance/security/security_checklis…
adriendupuis 4501d4c
Grammar
glye ead05a1
Merge branch 'checklist-file-system-permissions' into checklist-db
adriendupuis 9402cab
security_checklist.md: Format
adriendupuis abe2e28
Merge branch 'master' into checklist-db
adriendupuis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -140,6 +140,32 @@ The older UTF8 can lead to truncation with 4-byte characters, like some emoji, w | |||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
See [Change from UTF8 to UTF8MB4](update_db_to_2.5.md#change-from-utf8-to-utf8mb4). | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
### Use restricted DB user | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
The Data Definition Language (DDL) commands (create, alter, drop, truncate, comment) are only needed for installing and upgrading [[= product_name =]], and not for running it. | ||||||||||||||||||||||||||||||||||||||
Not granting these rights to web app users reduces the damage that can result from a security breach. | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
Create a user and grant minimal rights: | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
=== "MySQL" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
```sql | ||||||||||||||||||||||||||||||||||||||
CREATE USER 'user'@'host' IDENTIFIED BY 'password'; | ||||||||||||||||||||||||||||||||||||||
GRANT SELECT, INSERT, UPDATE, DELETE ON database_name.* TO 'user'@'host'; | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+153
to
+154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
=== "PostgreSQL" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
```sql | ||||||||||||||||||||||||||||||||||||||
CREATE USER user PASSWORD 'password'; | ||||||||||||||||||||||||||||||||||||||
GRANT CONNECT ON DATABASE database_name TO user; | ||||||||||||||||||||||||||||||||||||||
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO user; | ||||||||||||||||||||||||||||||||||||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO user; | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+160
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
In configuration, update users and passwords, such as [`DATABASE_URL`](install_ibexa_dxp.md#change-installation-parameters) | ||||||||||||||||||||||||||||||||||||||
or a [connection](repository_configuration.md#defining-custom-connection). | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
### Use secure Roles and Policies | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
Use the following checklist to ensure the Roles and Policies are secure: | ||||||||||||||||||||||||||||||||||||||
|
@@ -190,7 +216,11 @@ Once you have properly configured secure user roles and permissions, to avoid ex | |||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- Avoid exposing servers on the open internet when not strictly required. | ||||||||||||||||||||||||||||||||||||||
- Ensure any servers, services, ports and virtual hosts that were opened for testing purposes are shut down before going live. | ||||||||||||||||||||||||||||||||||||||
- Secure the database with a good password, keys, firewall, etc. Ensure that the database user used by the web app only has access to do the operations needed by [[= product_name =]]. The Data Definition Language (DDL) commands (create, alter, drop, truncate, comment) are not needed for running [[= product_name =]], only for installing and upgrading it. If the web app user does not have these rights, then that reduces the damage that can be done if there is a security breach. | ||||||||||||||||||||||||||||||||||||||
- Ensure file system permissions are set up such that the web server or PHP user can't access files they shouldn't be able to read. | ||||||||||||||||||||||||||||||||||||||
- Secure the database with a good password, keys, firewall, etc. | ||||||||||||||||||||||||||||||||||||||
Optionally, [restrict the database user](#use-restricted-db-user) to the needed operations. | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
Those steps aren't needed when using [[= product_name_cloud =]], where the provider handles them. | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
### Security headers | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't we need TCL commands here, too?
BEGINSTART TRANSACTION, COMMIT, ROLLBACK, SET at least?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have misinterpreted your remark at first. I thought it was about wrapping the commands in a transaction batch.
SET
could be added in PostgreSQL: https://www.postgresql.org/docs/current/sql-grant.html#SQL-GRANT-DESCRIPTION-OBJECTSI see no equivalent on MySQL: https://dev.mysql.com/doc/refman/8.4/en/privileges-provided.html