This vulnerability occurs when a function receives a direct reference to mutable data, such as an object or array, instead of a safe copy of that data.
When you pass a mutable object directly to a method—especially one from an external library or untrusted code—that method can alter or even delete the contents of your object. This breaks a fundamental assumption in your code: that the data you own remains under your control. The called function might change values, add unexpected elements, or clear the object entirely, leading to inconsistent states, crashes, or logic errors in your application. To prevent this, you should create and pass a defensive copy (a clone or deep copy) of the mutable data before sending it to any code you don't fully control. This ensures the original data remains intact and valid, regardless of what the external method does. Always treat mutable data passed across trust boundaries as potentially hostile and isolate it through copying.
Impact: Modify Memory
Potentially data could be tampered with by another function which should not have been tampered with.
cjava
// constructor for BookStore* public BookStore() { ``` this.inventory = new BookStoreInventory(); this.sales = new SalesDBManager(); ... } public void updateSalesAndInventoryForBookSold(String bookISBN) {
java
// Book object constructors and get/set methods* ...}
java
// Get book object from inventory using ISBN* Book book = inventory.getBookWithISBN(bookISBN);
javaMedium