The incident happened around 8.05am yesterday in a wooded area opposite the Glencourse Barracks in Penicuik.
A 44-year-old woman was walking her dog when a man approached and exposed himself to her.
The woman walked away and alerted an elderly man who was also walking his dog in the woods. The suspect then made off from the area.
Officers are now keen to hear from anyone who can help identify the male.
He is described as white, around 20-year-old, 5ft 8ins tall with a medium build and wearing a brown beanie hat, black jacket and blue jeans.
A police spokesman said: “The suspect did not say anything to the woman before exposing himself to her and at no point did she feel threatened.
“Nevertheless, we are treating this incident very seriously and would ask anyone who help us trace this male to contact police immediately.
“Similarly, we are keen to speak with the elderly man who was also walking his dog in the woods at the time and would urge him to come forward to assist with our enquiries.”
Anyone with any information is asked to contact Lothian and Borders Police on 0131 311 3131 or Crimestoppers in confidence and complete anonymity on 0800 555 111.