With various disadvantages of pollution control technologies for toxic metal-contaminated soil, we mixed contaminated soil with sludge for in situ composting to stabilize toxic metals, so plants are enriched to take up the toxic metals. When simulating the above, we added toxic metal solution into sewage sludge, and then composed it with steel slag to determine inhibition of the availability of toxic metals. When toxic metals were added into sludge, the potential ecological index and geoaccumulation index of Cd became high while Zn was low. Steel slag had an inhibited availability of Cd, and when the adjunction of steel slag was 7%, the availability of Cd was lowest. Steel slag promoted the availability of Zn, and when the adjunction of steel slag was 27%, the availability of Zn was highest. Results showed that during composting, with increasing steel slag, Cd stabilizing time was reached sooner but Zn stabilizing time was slower, and the availability of all metals became lower. In the end, composting inhibited the potential ecological index of Cd, but it promoted the potential ecological index of Zn. Steel slag promoted the stability of Cd and Zn as Fe/Mn oxide-bound and residual species. Therefore, composting sludge and steel slag could be used as an effective inhibitor of Zn and Cd pollution.