Looks to me like the banister is fine, but that piece of trim is pulling away. Give it a few good knocks with a hammer and add a few countersunk screws, making sure to hit the stud. Then just cover the screw heads with caulk, sand it smooth, and touch up the paint.