The first thing you need to do is pull up your state's landlord-tenant laws, because what your landlord is claiming doesn't automatically hold up everywhere. Most states have pretty strict rules about security deposits - they're meant to cover actual damages or unpaid rent, not to be forfeited just because you leave early. Breaking a lease is a separate issue from your deposit, and your landlord can pursue you for the remaining rent owed, but that doesn't give them the right to keep your deposit unless there's actual damage or unpaid rent to deduct from it.
The trickier part is the lease termination itself. Some states allow landlords to hold tenants to the full lease term if there's no early-exit clause, which means you could technically owe all four months. However, many states also recognize a landlord's duty to mitigate - meaning they should try to re-rent the unit instead of just collecting from you for the full term. If they find a new tenant or even could have found one, your liability drops. Check whether your state has this requirement and whether your landlord has actually tried to re-rent.
Before accepting what your landlord says, look up your state's specific rules (most state bar associations have summaries online, or search "[your state] tenant rights early termination"). Then send your landlord a written request asking them to itemize any damage or unpaid rent that would justify keeping the deposit, and ask what steps they're taking to re-lease the unit. Document everything in writing - texts or emails. If they won't budge and the numbers are significant enough, small claims court is an option in most states and doesn't require a lawyer.