To make a secret compartment, cut a square in the drywall behind the medicine cabinet, and affix a shelf made of 2-by-4 lumber within it. Position the cabinet appropriately over the cutout to hide it.
Begin making a secret compartment by tracing the perimeter of the medicine cabinet's back on the wall using a pencil. Open the cabinet, and locate the mounting screws. If the holes of the screws are keyhole-shaped, lift the cabinet, and slide it off the screws. Otherwise, remove the screws using a screwdriver.
Note the position of the screw holes of the cabinet on the wall, which indicates the stud position. Using your knuckles, rap on the gaps between the screw holes to know the end of the hollow area and the beginning of the stud's inner edge. Using a pencil, mark these spots.
Now, draw a square shape a few inches inside the traced square so it aligns with the pencil marks. Use a level to keep the lines straight. With a drywall saw, cut the smaller square to make a cutout in the wall.
Inside the cutout, measure the gap between the wall studs, and cut a 2-by-4 to an equal length. Position the cut lumber at the base of the cutout, and rest it horizontally between the wall studs using a level. Attach the shelf and the studs using wood screws and a cordless drill. Insert two screws per side of the shelf at angles of 45 degrees.
If desired, add more shelves in the cutout, and affix hooks to store a variety of valuables. Finally, replace the cabinet.