Suppose whole square and the left square in the diagram below are pullbacks, then we may wonder whether the right square is a pullback. It is usually not the case.

Now we seek some addition condition on $X\to Y$ that forces the right square is a pullback too.

My question: is epic a sufficient condition? (If the category is Sets, then yes.)

**Added**: Let $P$ be the pullback of the right square, then there exists $B\to P$, and the square $A\to P \to Y$ // $A\to X \to Y$ is a pullback, so we have the following diagram in which the bottom and the whole squares are pullback, so is the upper square. If the category is Sets, $X\to Y$ is surjective then $A\to P $ is also surjective. Since the pullback of $B\to P$ along a surjective map is an bijection, $B\to P$ must be a bijection. This shows the right square of the original diagram is a pullback. We can also see why we consider some nice condition on $X\to Y$.