Say that a second-order sentence in the empty language, $\varphi$, characterizes finiteness iff for every set $X$ we have $X\models\varphi$ iff $X$ is finite. I'm interested in the optimal complexity over $\mathsf{ZF}$ of sentences characterizing finiteness.
Many natural candidate sentences are $\Sigma^1_2$ (e.g. "$X$ admits a linear order which is well-ordered and co-well-ordered"), but we can do better: the sentence "$X$ can be linearly ordered and every linear ordering on $X$ is discrete" characterizes finiteness and is $\Sigma^1_1\wedge\Pi^1_1$. (Note that over $\mathsf{ZFC}$ we could drop the first clause, which would bring the comlpexity down to $\Pi^1_1$.)
Meanwhile,$\mathsf{ZF}$ alone proves that there is no $\Sigma^1_1$ sentence characterizing finiteness. First, note that $\mathsf{ZFC}$ proves the downward Lowenheim-Skolem theorem and that ultraproducts preserve $\Sigma^1_1$ sentences. From this we get that if $\varphi$ is $\Sigma^1_1$ and true in every finite structure then $\omega\models\varphi$ is true in $L$. But then by Mostowski absoluteness we in fact get $\omega\models\varphi$ in reality.
This leaves the $\Pi^1_1$ situation open:
Is there a $\Pi^1_1$ sentence in the empty language which $\mathsf{ZF}$ proves characterizes finiteness? Equivalently, is there a first-order sentence $\psi$ (in any language) such that $\mathsf{ZF}$ proves that the cardinalities of models of $\psi$ are exactly the infinite cardinalities?
My suspicion is that the answer is no - indeed, that every amorphous set satisfies all $\Pi^1_1$ sentences true in all finite sets. However, at the moment I don't see how to prove even the weaker claim.
EDIT: note that a negative answer to the question (which James Hanson has provided below) also shows that no $\Sigma^1_1\vee\Pi^1_1$ sentence can characterize finiteness. Suppose $\psi\in\Sigma^1_1$, $\theta\in\Pi^1_1$, and $\psi\vee\theta$ is true in every finite structure. Then either $\psi$ has arbitrarily large finite models in which case $\psi$ has an infinite model, or for some $n\in\omega$ the $\Pi^1_1$ sentence "$\theta\vee[\forall x_1,...,x_{n+1}(\bigvee_{1\le i<j\le n+1}x_i=x_j)]$" is true of every finite structure and hence has an infinite model. Either way, $\psi\vee\theta$ has an infinite model. So James' answer in fact completely resolves the complexity of finiteness over $\mathsf{ZF}$.