Natural resources are found in sedimentary basins across the world. The growing focus on decarbonisation and energy transition have led to significant advances in our understanding for CO2 and hydrogen storage potential in dynamic sedimentary basins. The effective storage of CO2 is dependent on the existence of conditions required to keep CO2 stable on human timescales and prevent leakage that will undoubtedly cause environmental problems. These conditions include existence and effectiveness of geological seals to prevent leakage and absence of features, e.g., faults, which may act as conduits for CO2. However, given the fundamental chemistry of CO2 and the fact that the triple point is at conditions encountered at shallow depths (Pc = 7.38 MPa, Tc = 30.98oC), there is an obvious question: do variations in surface temperature affect the condition of CO2 in the subsurface? If so, can surface or near-surface temperature variations caused by climate change or urbanisation affect the depths for which CO2 will remain stable for storage in rocks? We have developed a new algorithm to calculate the vertical velocities of CO2 and hydrogen in sandstones and carbonates in sedimentary basins and at depths above ~2 km. Our results indicate that the depth of the CO2 gas-liquid or gas-supercritical phase boundary may change by hundreds of meters due to the perturbations in heat flow in sedimentary basins. Furthermore, hydrogen velocities may be 2-10 times greater than those of hydrocarbons at similar depths. Hence, important considerations must be made when constructing dynamic basin models to estimate the future migration pathways for CO2 and hydrogen resource potential.