Safer Log Files

Safer Log Files

Rocco Gagliardi
by Rocco Gagliardi
time to read: 6 minutes

We have (securely) collected a lot of event records from sparse generators, centrally consolidated and archived in a daily rotated archive. Which measures can we take in place to protect the content of the archives?

Protecting Log Files

File attributes will help. BSDs have the ability to assign extra attributes to files and directories (Linux has similar features, but who uses Linux in a secure environment? Ok! take it easy, it’s a joke… but still use OpenBSD, please). This is different from the standard Unix permissions scheme in that the attributes set on a file apply universally to all users of the system, and they affect file accesses at a much deeper level than file permissions or ACLs.

Use ls -lo to view the attributes and use chflags to modify them.

One useful attribute for protecting log files is append-only. When this attribute is set, the file cannot be deleted and writes are only allowed to append to the end of the file.

# chflags sappnd filename

But this is just the half of the game: root (or a pretending one) can still remove the attribute, change the log and restore the attribute without any notice (except for the last operation: restoring the attribute).

To prevent this, you’ll need to disable the ability to remove the append-only attribute.

The BSDs accomplish this thing through the use of securelevels. The securelevel is a kernel variable that you can set to disallow certain functionality. Raise the securelevel to 1. Once the securelevel has been set to a value greater than 0, it cannot be lowered. By default, OpenBSD will raise the securelevel to 1 when in multiuser mode. In FreeBSD, the securelevel is –1 by default.

To change this behavior, add the following line to /etc/sysctl.conf:

kern.securelevel=1

Be aware that adding append-only flags to your log files will most likely cause log rotation scripts to fail. However, it is a valuable enhancement of the security of your audit trail.

Maintain Integrity

Basically, we want to protect log files from tampering, poisoning or forgery. This kind of techniques can be referred to as integrity verification, incontrovertible data, court admissible evidentiary data or even signed and sequenced data.

What methods can we use?

Summary

Why so serious about logfile security? If we can’t prove or at least reasonably trust our logs, we are blind. Keeping log secure and verifiable is one of the most complex part of the log management solution. Many solutions exist to address the problem but must be implemented very carefully. And the clouds does not promise anything good!

References

About the Author

Rocco Gagliardi

Rocco Gagliardi has been working in IT since the 1980s and specialized in IT security in the 1990s. His main focus lies in security frameworks, network routing, firewalling and log management.

Links

You want to bring your logging and monitoring to the next level?

Our experts will get in contact with you!

×
Enhancing Data Understanding

Enhancing Data Understanding

Rocco Gagliardi

Transition to OpenSearch

Transition to OpenSearch

Rocco Gagliardi

Graylog v5

Graylog v5

Rocco Gagliardi

auditd

auditd

Rocco Gagliardi

You want more?

Further articles available here

You need support in such a project?

Our experts will get in contact with you!

You want more?

Further articles available here