I asked this question on Mathematics Stackexchange, but got no answer.

Let $B$ be a commutative ring with $1$, let $A$ be a subring such that any unit of $B$ which belongs to $A$ is a unit of $A$, and let $\phi:F\to F$ be an endomorphism of a free $A$-modules $F$ such that $B\otimes_A\phi:B\otimes_AF\to B\otimes_AF$ is an automorphism.

Does this imply that $\phi$ is an automorphism?

The answer is of course yes if $F$ has finite rank, by determinant theory.

The answer is also yes if $B$ is faithfully flat over $A$.

Julian Rosen made the following interesting comment on Mathematics Stackexchange:

"Choose bases for $F,F'$, and write $[\phi]$ (resp. $[\phi^{-1}]$) for the matrix of $\phi$ (resp. $(B\otimes\phi)^{-1}$), which is a column-finite (possibly) infinite with entries in $A$ (resp. $B$). WLOG we may assume $B$ is generated as an $A$-algebra by the entries of $[\phi^{-1}]$. If two ring homomorphisms $f,g:B\to C$ agree on $A$, both $f([\phi^{-1}])$ and $g([\phi^{-1}])$ are inverses of $f([\phi])=g([\phi])$, so $f([\phi^{-1}])=g([\phi^{-1}])$ and hence $f=g$ (here functions act on matrices entry-wise). This means $A\to B$ is an epimorphism of rings. An example of an injective ring epimorphism introducing no new units is $k[x^2,x(x^2-1)]\subset k[x,(x-1)^{-1}]$ (see this MO answer), so if a counterexample exists this might be a place to start."

Here $k$ is a field of characteristic $\ne2$. (For an elementary proof of the fact that the inclusion $k[x^2,x(x^2-1)]\subset k[x,(x-1)^{-1}]$ is an epimorphism, see this text.)