All Projects → ikkisoft → Serialkiller

ikkisoft / Serialkiller

Licence: apache-2.0
Look-Ahead Java Deserialization Library

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Serialkiller

terraform-aws-secure-vpc
A terraform module to create a VPC with secure default configurations.
Stars: ✭ 13 (-95.31%)
Mutual labels:  security-hardening
TermiNetwork
🌏 A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.
Stars: ✭ 80 (-71.12%)
Mutual labels:  deserialization
reflective-rapidjson
Code generator for serializing/deserializing C++ objects to/from JSON using Clang and RapidJSON
Stars: ✭ 26 (-90.61%)
Mutual labels:  deserialization
SIPTorch
A "SIP Torture" (RFC 4475) testing suite.
Stars: ✭ 54 (-80.51%)
Mutual labels:  security-hardening
wazuh-puppet
Wazuh - Puppet module
Stars: ✭ 25 (-90.97%)
Mutual labels:  security-hardening
amq-protocol
AMQP 0.9.1 protocol serialization and deserialization implementation for Ruby (2.0+)
Stars: ✭ 47 (-83.03%)
Mutual labels:  deserialization
awesome-rails-security
A curated list of security resources for a Ruby on Rails application
Stars: ✭ 36 (-87%)
Mutual labels:  security-hardening
Krane
Kubernetes RBAC static Analysis & visualisation tool
Stars: ✭ 254 (-8.3%)
Mutual labels:  security-hardening
dataconf
Simple dataclasses configuration management for Python with hocon/json/yaml/properties/env-vars/dict support.
Stars: ✭ 40 (-85.56%)
Mutual labels:  deserialization
Pickora
A toy compiler that can convert Python scripts 🐍 to pickle bytecode 🥒
Stars: ✭ 50 (-81.95%)
Mutual labels:  deserialization
jzon
A correct and safe JSON parser.
Stars: ✭ 78 (-71.84%)
Mutual labels:  deserialization
hapic
Input/Output/Error management for your python controllers with Swagger doc generation
Stars: ✭ 18 (-93.5%)
Mutual labels:  deserialization
jsonapi-deserializable
Conveniently deserialize JSON API payloads into custom hashes.
Stars: ✭ 23 (-91.7%)
Mutual labels:  deserialization
phar-stream-wrapper
Interceptors for PHP's native phar:// stream handling in order to enhance security.
Stars: ✭ 54 (-80.51%)
Mutual labels:  deserialization
UBUNTU18-CIS
CIS Baseline Ansible Role for Ubuntu 18
Stars: ✭ 20 (-92.78%)
Mutual labels:  security-hardening
wazuh-cloudformation
Wazuh - Amazon AWS Cloudformation
Stars: ✭ 32 (-88.45%)
Mutual labels:  security-hardening
AvroConvert
Apache Avro serializer for .NET
Stars: ✭ 44 (-84.12%)
Mutual labels:  deserialization
Inquiry Deprecated
[DEPRECATED]: Prefer Room by Google, or SQLDelight by Square.
Stars: ✭ 264 (-4.69%)
Mutual labels:  deserialization
Electriceye
Continuously monitor your AWS services for configurations that can lead to degradation of confidentiality, integrity or availability. All results will be sent to Security Hub for further aggregation and analysis.
Stars: ✭ 255 (-7.94%)
Mutual labels:  security-hardening
moonwlker
Jackson JSON without annotation.
Stars: ✭ 14 (-94.95%)
Mutual labels:  deserialization

SerialKiller SerialKiller Logo

SerialKiller is an easy-to-use look-ahead Java deserialization library to secure application from untrusted input.

When Java serialization is used to exchange information between a client and a server, attackers can replace the legitimate serialized stream with malicious data. Inspired by this article, SerialKiller inspects Java classes during naming resolution and allows a combination of blacklisting/whitelisting to secure your application.

SerialKiller in action

Disclaimer: This library may (or may not) be 100% production ready yet. Use at your own risk!

How to protect your application with SerialKiller

  1. Download the latest version of the SerialKiller's Jar. Alternatively, this library is also available on Maven Central
  2. Import SerialKiller's Jar in your project
  3. Replace your deserialization ObjectInputStream with SerialKiller
  4. Tune the configuration file, based on your application requirements

Easy, isn't it? Let's look at a few details...

Changes required in your code (step 3)

In your original code, you'll probably have something similar to:

ObjectInputStream ois = new ObjectInputStream(is);
String msg = (String) ois.readObject();

In order to detect malicious payloads or allow your application's classes only, we need to use SerialKiller instead of the standard java.io.ObjectInputStream. This can be done with a one-line change:

ObjectInputStream ois = new SerialKiller(is, "/etc/serialkiller.conf");
String msg = (String) ois.readObject();

The second argument is the location of SerialKiller's configuration file.

Finally, you may want to catch InvalidClassException exceptions to gracefully handle insecure object deserializations. Please note that this library does require Java 8.

Tuning SerialKiller's configuration file (step 4)

SerialKiller config supports the following settings:

  • Refresh: The refresh delay in milliseconds, used to hot-reload the configuration file. Good news! You don't need to restart your application if you change the config file
  • BlackList: A Java regex to define malicious classes. The default configuration file already includes several known payloads so that your application is protected by default against known attacks
  • WhiteList: A Java regex to define classes used by your application. If you can quickly identify a list of trusted classes, this is the best way to secure your application. For instance, you could allow classes in your own package only
  • Profiling: Starting from v0.4, SerialKiller introduces a profiling mode to enumerate classes deserialized by the application. In this mode, the deserialization is not blocked. To protect your application, make sure to use 'false' for this setting in production (default value)
  • Logging: Logging support compatible to native LogManager using the java.util.logging.config.file system property or lib/logging.properties. See Java8 LogManager for more details.

Example of serialkiller.conf

<?xml version="1.0" encoding="UTF-8"?>
<!-- serialkiller.conf -->
<config>
  <refresh>6000</refresh>
  <mode>
    <!-- set to 'false' for blocking mode -->
    <profiling>false</profiling>
  </mode>
  <blacklist>
  <!--Section for Regular Expressions-->
    <regexps>
        <!-- ysoserial's BeanShell1 payload  -->
        <regexp>bsh\.XThis$</regexp>
        <regexp>bsh\.Interpreter$</regexp>
        <!-- ysoserial's C3P0 payload  -->
        <regexp>com\.mchange\.v2\.c3p0\.impl\.PoolBackedDataSourceBase$</regexp>
	    <!-- ysoserial's MozillaRhino1 payload -->
	    <regexp>org\.mozilla\.javascript\..*$</regexp>
        [...]
    </regexps>
    <!--Section for full-package name-->
    <list>
        <!-- ysoserial's CommonsCollections1,3,5,6 payload  -->
        <name>org.apache.commons.collections.functors.InstantiateTransformer</name>
        <name>org.apache.commons.collections.functors.ConstantTransformer</name>
        <name>org.apache.commons.collections.functors.ChainedTransformer</name>
        <name>org.apache.commons.collections.functors.InvokerTransformer</name>
        [...]
    </list>
  </blacklist>
  <whitelist>
    <regexps>
        <regexp>.*</regexp>
    </regexps>
  </whitelist>
</config>

Credits

  • Ironically, SerialKiller uses some Apache Commons libraries (configuration, logging, lang, collections)
  • Thanks to @frohoff and @gebl for their work on unsafe Java object deserialization payloads. Ysoserial is awesome!
  • Pierre Ernst for the original idea around look-ahead java deserialization filters

License

This library has been dual-licensed to Apache License, Version 2.0 and GNU General Public License.

Contributing

  • If you've discovered a bug, please open an issue in Github.
  • Submit a new RB, especially if you're aware of Java gadgets that can be abused by vulnerable applications. Providing a safe default configuration is extremely useful for less security-oriented users.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].