That is absolutely possible. In fact it's even possible to get your cost basis to be negative. However, it requires that you use a different definition of the term "cost basis" than is used by the IRS.
Basically, all buys and sells are totalled up to provide a total "cash flow out" for the position. Divide this by the number of shares you have, and that's your "cost basis". Here's an example:
Buy 100 ABC at 5: ($500 out)
Sell 50 ABC at 7: ($350 in)
Buy 100 ABC at 4: ($400 out)
Sell 100 ABC at 8: ($800 in)
Now I have 50 shares. My total cash flow is a POSITIVE $250, and another way of looking at this is that I have a total out-of-pocket cost of negative $250. So my "cost basis" on this position is negative $5/share.