Is it hard to switch from a MS to PhD program?

Many highly ranked academic MS programs allow students to transfer into the PhD program after completing the MS.  Examples in computer science include UIUC, Purdue, and Minnesota. A common expectation in these cases is that the student will have engaged in research during their MS, and an application to the PhD program may be expected.

Some universities offer combined MS-PhD program for full-time graduate students (e.g., UW CSE). Students in these programs have the choice to leave with their MS or stay for a PhD without completing another application. Such programs can be quite competitive and will typically only admit students who demonstrate potential and desire to complete a PhD.

Some departments offer pre-doctoral MS programs that do not provide a direct pipeline into their own PhD program, but do prepare students to become more competitive PhD applicants by taking research-oriented classes and working with a research advisor. Examples include U of Chicago and Stanford.

Completing an MS does not necessarily lead to preferential access to the PhD program at that same institution. If a department does not advertise a dedicated path from their MS program to their PhD, it is likely that you will have to submit a full application to their PhD program, and be considered along with all of the external applicants.