We study self-avoiding walks on the square lattice restricted to a square box of side L weighted by a length fugacity without restriction of their end points. This is a natural model of a confined polymer in dilute solution such as polymers in mesoscopic pores. The model admits a phase transition between an ‘empty’ phase, where the average length of walks are finite and the density inside large boxes goes to zero, to a ‘dense’ phase, where there is a finite positive density. We prove various bounds on the free energy and develop a scaling theory for the phase transition based on the standard theory for unconstrained polymers. We compare this model to unrestricted walks and walks that whose endpoints are fixed at the opposite corners of a box, as well as Hamiltonian walks. We use Monte Carlo simulations to verify predicted values for three key exponents: the density exponent $$\alpha =1/2$$
α
=
1
/
2
, the finite size crossover exponent $$1/\nu =4/3$$
1
/
ν
=
4
/
3
and the critical partition function exponent $$2-\eta =43/24$$
2
-
η
=
43
/
24
. This implies that the theoretical framework relating them to the unconstrained SAW problem is valid.