I'm trying to prove the statement in the title, which is a step in the proof of a lemma in Kunen's The Foundations of Mathematics. Proceeding by contradiction, let $f:\lambda\to\kappa$ be unbounded, and put $X=\text{ran}(f)$. Since $\sup X=\kappa$, we have, by definition of cofinality $$\lambda<\text{cf}(\kappa)\le \text{type}(X)$$ Now, since $\text{cf}(\kappa)$ is regular, it is a cardinal, and since $\lambda$ is also a cardinal, we deduce that $\lambda \prec \text{cf}(\kappa)$, i.e. there is no injection from $\lambda$ into $\kappa$. Then, since $f$ is a surjection from $\lambda$ onto $X$ (I'm assuming Choice throughout this whole question) $$\lambda\prec \text{cf}(\kappa)\preceq\text{type}(X)\preceq \lambda$$ which is a contradiction (note the subtle change in typography from $<$ to $\prec$).
Is this argument correct? Is there any easier way to see it? Kunen does not have a tendency to make huge leaps, and while this isn't too difficult, he offers no justification, which is a tad strange.
EDIT: To clarify, $\text{type}(X)$ is the unique ordinal isomorphic to $(X,\in)$, and Kunen defines
$$\text{cf}(\kappa)=\min\{\text{type}(X): X \subset \kappa, \sup X =\kappa\}$$
Your argument works, provided that all of the necessary machinery is in place; not having seen the book, I can’t judge that. I would argue a bit more explicitly:
By the definition of cofinality there is a set $C=\{\gamma_\xi:\xi<\operatorname{cf}\kappa\}$ such that $\sup C=\kappa$ and $\gamma_\xi<\gamma_{\xi+1}$ for each $\xi<\operatorname{cf}\kappa$. Since $\sup X=\kappa$, for each $\eta<\operatorname{cf}\kappa$ we can let
$$g(\eta)=\min\left\{\xi<\lambda:f(\xi)>\max\big\{\gamma_\eta,\sup\{g(\zeta)+1:\zeta<\eta\}\big\}\right\}\;.$$
Then $g$ is an injection (indeed, a strictly increasing function) from $\operatorname{cf}\kappa$ into $\lambda$, contradicting the hypothesis that $\lambda<\operatorname{cf}\kappa$.
Note that there’s no need for $\mathsf{AC}$ anywhere. This is the case in your argument as well, since both the domain and the range of $f$ come equipped with well-orders.