Lumber treated with CCA (chromated copper arsenate) can leach into the soil and be taken up into plants. This is a concern especially for root crops (carrots, potatoes).
However, CCA was taken off the market in 2004 by EPA. Since that time, the treated lumber that you buy in stores often uses ACQ technology (alkaline copper quaternary ammonium). This alternative wood-treatment chemical contains no arsenic, chromium, or any other chemical considered toxic by the EPA. ACQ does contain copper, and copper may still leach from ACQ-treated lumber. But based on several studies, ACQ treated lumber is considered safe for use in vegetable gardens. Here is one you can check out: https://hero.epa.gov/hero/index.cfm/reference/details/reference_id/1345002
If you are still concerned about using treated lumber, here are some alternative materials:
- Naturally decay-resistant wood such as eastern or western red cedar, northern white cedar, Osage orange, white oak, locust, or redwood.
- Plastic lumber, concrete blocks, brick, or stone; wire mesh for compost bins.