Safeguard
Application Security•

CWE-1070 Serializable Element Containing Non-Serializable Items

A serializable field that holds a non-serializable member will fail when written. CWE-1070 explains the problem and how to avoid it.

Safeguard Security Team
2 min read

CWE-1070 is a serializable, storable data element, such as a field or member, that contains member elements which are not serializable. It matters to anyone persisting or transmitting objects, for example in sessions, caches and queues.

How it happens

A class is marked serializable, and a field inside it points to an object that is not. The code compiles, then fails when the object is written.

// Pattern to avoid: Serializable outer class, non-serializable inner field
public class Job implements java.io.Serializable {
    private Thread worker;
}
// Better: mark runtime-only members as transient
public class Job implements java.io.Serializable {
    private transient Thread worker;
}

What an attacker gains

MITRE lists reduced reliability. If an attacker can reach the code, the problem "might introduce a vulnerability."

How to find it

The record lists no detection methods. Review serializable classes and check the type of each field. Tests that actually serialize and read back each class catch it quickly.

How to fix it

Make the inner type serializable, mark the member as transient, or store an identifier and rebuild the object afterward.

Quick check

When does this failure show up?

At the moment the object is written, not when the code is compiled.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.