Firebird 4.0 - BestPracticesSecurity
Firebird 4.0 - BestPracticesSecurity
Firebird 4.0 - BestPracticesSecurity
●
The popularity of SYSDBA based access is
understandable, but not secure
Users
●
Users are stored in security database
●
User names and hashes of passwords
●
Since Firebird 3 can be many security
databases
●
Authentication plugins (since Firebird 3)
●
Each plugin has own set of users
●
Yes, 2 SYSDBA with different passwords
can co-exist!
Authentication plugins
●
Auth plugins are dll/so libraries in folder
plugins, and specified in firebird.conf:
AuthServer = Srp, Legacy_Auth
●
Each plugin can have own list of users and,
optionally, UserManager
UserManager=Srp, Legacy_UserManager
Authentication plugins and User
Manager plugins
Authentication Plugin UserManager Plugin
Srp
Srp256 Srp
Legacy_Auth Legacy_UserManager
●
isql -user NEWUSER2 -pass 12345
●
Database: localhost:d:\o30-etalon.fdb,
User: NEWUSER2
●
SQL> exit;
Order of plugins
●
AuthServer = Srp, Legacy_Auth
●
AuthClient = Srp – changes the order
●
By default, without specification, Firebird
creates users using the first plugin defined
in UserManager parameter:
UserManager=Srp, Legacy_UserManager
●
CREATE USER usr PASSWORD ‘12345’;
●
Will be created with Srp
Authentication complete
●
Let’s talk about privileges of authenticated user
What objects to be secured?
Security DB
Security database
Users
SYS Password hashes
User NN User NN
DBA Roles
Database
Database 1
Tables
GeneratorNN records
Stored ProcedureNN
TriggerNN Views
ExceptionNN
Stored Procs
ViewNN
Roles
TableNN
Table1 TableNN Global actions
Record 1 Record 1 Create DB
Record 2 Record 2 Drop DB
Backup
Record NN Record NN ….
Privileges
●
Access to the objects
●
SELECT
●
INSERT, UPDATE, DELETE
●
EXECUTE
●
REFERENCES
●
Managing privileges
●
GRANT
●
REVOKE
●
Object management (DDL privileges)
●
CREATE
●
ALTER ANY
●
DROP ANY (ANY means access to non-owned
objects)
GRANT/REVOKE
●
GRANT <privileges>
TO <user>| <role>| <object>
●
REVOKE <privileges> FROM ...
●
Details are in Firebird Language Reference
and Release Notes
2. Best practices for Firebird
security
Out of the scope of Firebird security
●
Protection of server and database
●
From the direct and embedded access
●
From stealing
●
Consider encryption
●
Visit our “Firebird Database Encryption
workshop” tomorrow!
Firebird security tuning can protect:
1) From non-authorized access from valid
users
2) Brute force password attack
3) Access from unknown users
Don’t do, or useless SYSDBA role
●
In Firebird 2.5, it is possible to create SYSDBA
role (the same as SYSDBA), to protect from
SYSDBA access
●
Requires direct access to system tables
●
Does not work on Firebird 3!
●
Weak protection
●
If attacker has physical access to database
Best practices: server level-1
1) Enable “Over the wire” encryption to prevent
sniffing of users and password hashes
2) Use Srp256 and passwords 20+ symbols for
users (SHA-256)
3) Use option to fetch passwords from files (isql,
gbak, gfix):
1) Parameter -FE(TCH)
2) Easy change of passwords in all SQL scripts
Best practices: server level-2
1) Use separate security database for the
database (can be set in databases.conf)
2) Create users with privileges to create new
objects in database
1) Use SQL scripts to [re-]create users
2) Pseudo-Tables with List of Users to see the
whole picture
Best practices: database level-1
●
CREATE database with OWNER <> SYSDBA
●
Define necessary ROLEs to manage all types of
access
●
DDL privileges (GRANT
CREATE/ALTER_ANY/DROP_ANY <object>)
Best practices with ROLES-1
●
Roles can be granted to other Roles!
GRANT ROLE1 to BIGROLE
●
Easy to define more granular access
●
ROLE1 covers operations with T1, T2, etc
●
ROLE2 covers operations with
StoredProcedure1, SP2, etc
●
BIGROLE = ROLE1 AND ROLE
Best practices with ROLES-2
●
GRANT DEFAULT ROLE
●
Once user is created, it immediately receives
some default role:
●
Regular user
●
very restricted user
Record-level security
●
At the moment the only method in community
Firebird to implement record-level security is to
use stored procedures
●
Access is granted inside the logic of the stored
procedures
●
Views
●
For simple cases
Stored procedures privileges
●
Grant/revoke stored procedure to user
●
Grant revoke/stored procedure to other stored
procedure
●
In Firebird 4, new feature
●
SQL SECURITY DEFINER
●
to grant all privileges to stored procedure
●
Demo!
Why UDF are deprecated in 4.0?
●
Potential attack with UDF code
●
UDRs as replacement
●
UDR better protects from wrong parameters
and other mistakes
●
demo
3. Mappings: solution for external
users
External users
●
Some authentication plugins allow authentication
of external users
●
External user = not stored in Firebird security
database
●
Execute statement on external (plugin Cluster)
●
Server-wide plugins – WinSSPI
●
Special plugins (for example, LDAP
authentication)
Mappings
●
Mappings create relationships between users of
plugin and internal Firebird users and objects
●
Can be global mappings and database-level
mappings
●
Plugin can send to the mapping any specific
security object
●
E.g., WINSSPI transfers Windows groups and
domain administrator attribute
Authentication block (simplified)
NAME VALUE
WinSSPI
Plugin
USERNAME Alex
GROUP PowerUsers,
Users
Adminstrator Yes
Example of mapping for auth block
NAME VALUE