This is a personal blog. My other stuff: book | home page | Twitter | CNC robotics | electronics

July 15, 2015

Poland and the United States: all that begins must end

With my previous entry, I wrapped up an impromptu series of articles that chronicled my childhood experiences in Poland and compared the culture I grew up with to the American society that I'm living in today. For the readers who want to be able to navigate the series without scrolling endlessly, I wanted to put together a quick table of contents - so here it goes.

The entry that started it all:

  • "On journeys" - a personal story recounting my travels from Poland to the US.

Oh, the places you won't go:

Poland vs the United States:

And now, back to the regularly scheduled programming...

Poland vs the United States: American exceptionalism

This is the fourteenth article talking about Poland, Europe, and the United States. To explore the entire collection, start here.

This is destined to be the final entry in the series that opened with a chronicle of my journey from Poland to the United States, only to veer into some of the most interesting social differences between America and the old continent. There are many other topics I could still write about - anything from the school system to the driving culture - but with my parental leave coming to an end, I decided to draw a line. I'm sure that this decision will come as a relief for those who read the blog for technical insights, rather than political commentary :-)

The final topic I wanted to talk about is something that truly irks some of my European friends: the belief, held deeply by many Americans, that their country is the proverbial "city upon a hill" - a shining beacon of liberty and righteousness, blessed by the maker with the moral right to shape the world - be it by flexing its economic and diplomatic muscles, or with its sheer military might.

It is an interesting phenomenon, and one that certainly isn't exclusive to the United States. In fact, expansive exceptionalism used to be a very strong theme in the European doctrine long before it emerged in other parts of the Western world. For one, it underpinned many of the British, French, Spanish, and Dutch colonial conquests over the past 500 years. The romanticized notion of Sonderweg played a menacing role in German political discourse, too - eventually culminating in the rise of the Nazi ideology and the onset of World War II. It wasn't until the defeat of the Third Reich when Europe, faced with unspeakable destruction and unprecedented loss of life, made a concerted effort to root out many of its nationalist sentiments and embrace a more harmonious, collective path as a single European community.

America, in a way, experienced the opposite: although it has always celebrated its own rejection of feudalism and monarchism - and in that sense, it had a robust claim to being a pretty unique corner of the world - the country largely shied away from global politics, participating only very reluctantly in World War I, then hoping to wait out World War II up until being attacked by Japan. Its conviction about its special role on the world stage has solidified only after it paid a tremendous price to help defeat the Germans, to stop the march of the Red Army through the continent, and to build a prosperous and peaceful Europe; given the remarkable significance of this feat, the post-war sentiments in America may be not hard to understand. In that way, the roots of American exceptionalism differed from its European predecessors, being fueled by a fairly pure sense of righteousness - and not by anger, by a sense of injury, or by territorial demands.

Of course, the new superpower has also learned that its military might has its limits, facing humiliating defeats in some of the proxy wars with the Soviets and seeing an endless spiral of violence in the Middle East. The voices predicting its imminent demise, invariably present from the earliest days of the republic, have grown stronger and more confident over the past 50 years. But the country remains a military and economic powerhouse; and in some ways, its trigger-happy politicians provide a counterbalance to the other superpowers' greater propensity to turn a blind eye to humanitarian crises and to genocide. It's quite possible that without the United States arming its allies and tempering the appetites of Russia, North Korea, or China, the world would have been a less happy place. It's just as likely that the Middle East would have been a happier one.

Some Europeans show indignation that Americans, with their seemingly know-it-all attitudes toward the rest of the world, still struggle to pinpoint Austria or Belgium on the map. It is certainly true that the media in the US pays less attention to the old continent. But deep down inside, European outlets don't necessarily fare a lot better, often focusing on the silly and the formulaic: when in Europe, you are far more likely to hear about a daring rescue of a cat stuck on a tree in Wyoming, or about the Creation Museum in Kentucky, than you are to learn anything substantive about Obamacare. (And speaking of Wyoming and Kentucky, pinpointing these places on the map probably wouldn't be the viewers' strongest feat). In the end, Europeans who think they understand the intricacies of US politics are probably about as wrong as the average American making sweeping generalizations about Europe.

And on that intentionally self-deprecating note, it's time to wrap the series up.

Poland vs the United States: work and entitlements

This is the thirteenth article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

In one of my earlier posts, I alluded to the pervasive faith in the American Dream: the national ethos of opportunity, self-sufficiency, and free enterprise that influences the political discourse in the United States. The egalitarian promise of the American Dream is simple: no matter who you are, hard work and ingenuity will surely allow you to achieve your dreams. From that, it follows that on your journey, you are not entitled to much; the government will be there to protect your freedom, but it will not give you a head start.

Unlike many of my peers, I suspect that there is some truth to the cliche; the United States is a remarkably industrious nation and the home to many of the world's most innovative and fastest-growing businesses. It certainly trods ahead of European economies, still dominated by pre-war conglomerates and former state monopolists, and weighed down by aging populations and out-of-control costs. America's mostly-self-made magnates, the likes of Bill Gates and Warren Buffett, are also far more likable and seemingly more human than Europe's stereotypical caste of aristocratic families and shadowy oligarchs.

On the flip side, the striking upward mobility of rags-to-riches icons such as Steve Jobs or Oprah Winfrey tends to be an exception, not a rule. Many scholars point out that parents' incomes are highly predictive of the incomes of their children - and that in the US, this effect is more pronounced than in some of the European states. Their studies looked at the mobility between predefined income quantiles, thus grossly overestimating the mobility in less unequal societies, where even a modest salary jump would move you up a notch - but ultimately, there is no denying that people who are born into poor families will usually remain poor for the rest of their lives. And with the contemporary trends in outsourcing and industrial automation, the opportunities for unskilled blue collar labor - once a key stepping stone in the story of the American Dream - are shrinking fast.

In contrast with the United States, many in Europe hold that it is a basic human right to be able to live a good life or to have an honest and respectable job. This starts with the labor law: in much of the United States, firing an employee can happen in the blink of an eye, for almost any reason - or without giving a reason at all. In Europe, the employer will need a just cause and will go through a lengthy severance period; depending on the circumstances, the company may be also barred from hiring another person to do the same job. Employment benefits follow the same pattern; in the US, paid leave is largely up to employers to decide, with skilled workers being lured with packages that would make Europeans jealous - but many unskilled laborers, especially in the retail and restaurant business, getting the short end of that stick.

In Europe, enabling the disadvantaged to contribute to the society and to live fulfilling lives is also a matter of government policy, often implemented through sweeping wealth redistribution. Such efforts tend to be more successful in small and wealthy Scandinavian countries, where the society can be engineered with more finesse. In many other parts of the continent, systemic, long-term poverty is still rampant, with the government being able to do little more than providing people with a lifetime of subsidized basic sustenance and squalor living conditions. It is certainly an improvement compared to many places in America, but a far cry from enabling them to re-enter the workforce and to live happy, productive lives.

Interestingly, when it comes to the benefits that are most frequently described as inadequate within the US, the disparity with Europe is not as striking as it may seem. For example, the minimal wage is quite comparable; it is around $2.60 per hour in Poland, about $3.70 in Greece, some $9.30 in Germany, and in the ballpark of $10.00 in the UK. In the US, the national average hovers somewhere around $8.00, with some of the states with higher costs of living on track to raise it to $10.00 within a year or two.

Unemployment and retirement benefits, although certainly not lavish, also follow the same pattern. When it comes to unemployment in particular, in the States, workers are entitled to about half of their previous salary for up to six months - although that period has been extended to more than a year in times of economic calamity. In Europe, the figures are roughly comparable, with payments in the ballpark of 50-70% of your previous salary, typically extending for somewhere between 6 and 12 months. The main difference is that the upper limit for monthly benefits tends to be significantly lower in the US than in Europe, often putting far greater strain on single-income families in places with high cost of living. In France, the ceiling seems to be around $8,000 a month; in the US, you will probably see no more than $2,000.

Many of the conservatives who preach the virtues of the American Dream vastly underestimate the pervasive and lasting consequences of being born into poverty or falling onto hard times; they also underestimate the role that privilege and luck played in their own lives. The progressives often do no better, seeing European social democracies as a flawless role model and portraying the rich as Mr. Burns-esque villains of unfathomable wealth and but one goal: to avoid paying taxes at any cost. In the end, helping the disadvantaged is a moral imperative - but simple solutions are hard to come by, and grabbing the pitchforks to start a revolution may be premature.

For the next and final article in the series, click here.

July 14, 2015

Poland vs the United States: governance

This is the twelfth article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

The American model of government is a complex beast. To a visitor from continental Europe, accustomed to the Napoleonic traditions of civil law and to the political realities of unitary states, the sight can be also a bit perplexing: after all, how does a country of this size prosper with a bitterly partisan, gridlocked Congress that repeatedly fails to even pass the budget on time? And how is it possible that, with an approval rating of 15%, the elected officials are not facing a wave of widespread social unrest?

I suspect that the key to solving this riddle lies in the fact that the United States is still very much a federation of self-governing states - and that most of the decisions that affect the lives of ordinary citizens are not made in Washington. Each and every state establishes its own criminal and civil law, levies its own taxes, runs its own welfare systems, and appoints its own judges - sometimes by popular vote. In fact, the states routinely confer far-reaching powers onto individual municipalities: for example, most towns and counties operate their own, completely autonomous police departments that respond to local officials, not to a bigwig politician on the East Coast.

All this makes the government feel quite different from what you are likely to experience in Europe. Let's stick to law enforcement: in Poland and in some other European states, where the police are a part of a sprawling national bureaucracy, the citizens may have very few options for addressing concerns that do not rise to the level of national debate. In the US, dismantling the entire police force may seem trivial in comparison: the concerned citizens may need to get a local newspaper interested in their cause, then band together to recall the local official who is ultimately on the hook. Of course, the independence comes at a price: small, self-funded police departments can be quicker to adopt questionable practices that would not stand to broader scrutiny, such as baseless profiling or the rash application of civil forfeiture.

When it comes to the role of the federal government, the picture is complicated. In principle, the constitution gives it only a couple of duties; for example, the feds control various aspects of interstate commerce, print money, maintain armed forces, and handle foreign affairs. Of course, over the years, their responsibilities have expanded considerably, with the legislators exploiting the vagueness of the concept of "interstate commerce" in all sorts of creative ways. Today, the ongoing debate about the appropriate boundaries of this practice fuels the partisan gridlock in Washington. The Republicans, swayed by the conservative Tea Party movement, argue that the feds should not meddle in the affairs of the states (they are particularly hawkish on this principle when the states try to stick to more traditional social principles). The Democratic party, taking notes from the vaguely leftist Occupy campaign, increasingly sees the federal government as a flexible tool for establishing country-wide standards of environmental protection, labor rights, welfare, gun control, and other progressive causes historically associated with European social democrats.

Owing to the parties' newly-found tendency to pander to populist fringes and their inability to compromise, the dysfunctional Congress gets very little love from the average voter; but somewhat paradoxically, the representatives from each and every district are usually well-liked by their own constituents and get reelected with ease. Some blame gerrymandering, but a simpler explanation exists: most of the candidates have strong ties to the districts they represent, many of them having a track record as local politicians or successful businessmen. As a result, they live and die at the mercy of local newspapers, often lending a hand to the voters who write or call them to resolve bureaucratic hurdles and address other everyday grievances. The practice of getting your representatives involved in such matters is almost unthinkable in Poland, where the spots on local ballots are traded by party officials - and are routinely handed out to people with little or no connection to the region they are supposed to represent.

With American political campaigns financed from private funds, it is often argued that the representatives in Congress are disproportionately influenced by the wealthy few and by a variety of organized lobby groups. This is likely true, although the disparity is at least partly offset by the public's fascination with human interest stories and the tendency to root for the common folk. Ultimately, even the most cynical congresspeople can afford to be persuaded by money only when it comes to the topics that their constituents are fairly indifferent to.

Beyond the legislative and executive branches of the government, some distinct undertones of self-governance are present in the US judicial system, too. The country borrows from the traditions of British common law, rather than the civil law system utilized in much of continental Europe. It embraces the significance of legal precedent and emphasizes humanist values over the strict application of legal codes, with remarkably broad powers vested in the judges and in the juries of peers - up to the notion of jury nullification. Ultimately, the system seeks to limit the consequences of the fallibility of legislators, who often struggle to properly consider all the implications of the laws they pass; it trades it for the increased risk of fallible courts - who bring in their own subconscious biases into the mix.

For the next article in the series, click here.

July 06, 2015

Poland vs the United States: immigration

This is the eleventh article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

There are quite a few corners of the world where the ratio of immigrants to native-born citizens is remarkably high. Many of these places are small or rapidly growing countries - say, Monaco or Qatar. Some others, including several European states, just happen to be on the receiving end of transient, regional demographic shifts; for example, in the past decade, over 500,000 people moved from Poland to the UK. But on the list of foreigner-friendly destinations, the US deserves a special spot: it is an enduring home to by far the largest, most diverse, and quite possibly best-assimilated migrant population in the world.

The inner workings of the American immigration system are a fascinating mess - a tangle of complex regulation, of multiple overlapping bureaucracies, and of quite a few unique social norms. The bureaucratic machine itself is ruthlessly efficient, issuing several million non-tourist visas and processing over 700,000 naturalization applications every year. But the system is also marred by puzzling dysfunction: for example, it allows highly skilled foreign students to attend US universities, sometimes granting them scholarships - only to show many of them the door the day they graduate. It runs a restrictive H-1B visa program that ties foreign workers to their petitioning employers, preventing them from seeking better wages - and thus needlessly making the American labor a bit less competitive. It also neglects the countless illegal immigrants who, with the tacit approval of legislators and business owners, prop up many facets of the economy - but are denied the ability to join the society even after decades of staying out of trouble and doing honest work.

Despite being fairly picky about the people it admits into its borders, in many ways, the United States is still an exceptionally welcoming country: very few other developed nations unconditionally bestow citizenship onto all children born on their soil, run immigration lotteries, or allow newly-naturalized citizens to invite their parents, siblings, and adult children over, no questions asked. At the same time, the US immigration system has a shameful history of giving credence to populist fears about alien cultures - and of implementing exclusionary policies that, at one time or another, targeted anyone from the Irish, to Poles, to Arabs, to people from many parts of Asia or Africa. Some pundits still find this sort of scaremongering fashionable, now seeing Mexico as the new threat to the national identity and to the American way of life. The claim made very little sense 15 years ago - and makes even less of it today, as the migration from the region has dropped precipitously and has been eclipsed by the inflow from other parts of the world.

The contradictions, the dysfunction, and the occasional prejudice aside, what always struck me about the United States is that immigration is simply a part of the nation's identity; the principle of welcoming people from all over the world and giving them a fair chance is an axiom that is seldom questioned in any serious way. When surveyed, around 80% Americans can identify their own foreign ancestry - and they often do this with enthusiasm and pride. Europe is very different, with national identity being a more binary affair; I always felt that over there, accepting foreigners is seen as a humanitarian duty, not an act of nation-building - and that this attitude makes it harder for the newcomers to truly integrate into the society.

In the US, as a consequence of treating contemporary immigrants as equals, many newcomers face a strong social pressure to make it on their own, to accept American values, and to adopt the American way of life; it is a powerful, implicit social contract that very few dare to willingly renege on. In contrast to this, post-war Europe approaches the matter differently, seeing greater moral value in letting the immigrants preserve their cultural identity and customs, with the state stepping in to help them jumpstart their new lives through a variety of education programs and financial benefits. It is a noble concept, although I'm not sure if the compassionate European approach always worked better than the more ruthless and pragmatic American method: in France and in the United Kingdom, massive migrant populations have been condemned to a life of exclusion and hopelessness, giving rise to social unrest and - in response - to powerful anti-immigrant sentiments and policies. I think this hasn't happened to nearly the same extent in the US, perhaps simply because the social contract is structured in a different way - but then, I know eminently reasonable folks who would disagree.

As for my own country of origin, it occupies an interesting spot. Historically a cosmopolitan nation, Poland has lost much of its foreign population and ethnic minorities to the horrors of World War II and to the policies implemented within the Soviet Bloc - eventually becoming one of the most culturally and ethnically homogeneous nations on the continent. Today, migrants comprise less than 1% of its populace, and most of them come from the neighboring, culturally similar Slavic states. Various flavors of xenophobia run deep in the society, playing right into the recent pan-European anti-immigration sentiments. As I'm writing this, Poland is fighting the European Commission tooth and nail not to take three thousand asylum seekers from Syria; many politicians and pundits want to first make sure that all the refugees are of Christian faith.

For the next article in the series, click here.

July 05, 2015

Poland vs the United States: crime and punishment

This is the tenth article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

Throughout much of its history, the United States has been a violent nation. From the famed lawlessness of the western frontier, to the brawling biker gangs, to the iconic Italian Mafia and the fearsome Mexican drug cartels, the thirst for blood has left a mark on the American psyche - and profoundly influenced many of the country's most cherished works of literary and cinematic art.

But sooner or later, a line gets drawn. And so, when a tidal wave of violent crime swept the nation in the late 80s, the legislators and the executive branch felt obliged to act. Many wanted to send a message to the criminal underworld by going after it with relentless and uncompromising zeal - kicking off the multi-decade War on Drugs and rolling out policies such as the three strikes law in California or stop-and-frisk in New York City. Others saw the root of all evil in the pervasive gun culture of the United States - successfully outlawing the possession or carry of certain classes of firearms and establishing a nation-wide system of background checks.

And then, in the midst of these policy changes, something very interesting started to unfold: the crime rate plunged like a rock, dropping almost 50% over the course of twenty years. But why? Well, the funny thing is, nobody could really tell. The proponents of tough policing and the War on Drugs tooted their own horns; but less vindictive municipalities that adopted programs of community engagement and proactive policing heralded broadly comparable results. Gun control advocates claimed that getting assault rifles and handguns off the streets made a difference; gun rights activists found little or no crime gap between the gun-friendly and the gun-hostile states. Economists pointed out that people were living better, happier, and longer lives. Epidemiologists called out the elimination of lead - an insidious developmental neurotoxin - from paints and gasoline. Some scholars have gone as far as claiming that easy access to contraception and abortion caused fewer children to be born into multi-generational poverty and to choose the life of crime.

Europe certainly provided an interesting contrast; the old continent, having emerged from two unspeakably devastating and self-inflicted wars, celebrated its newly-found pacifist streak. Its modern-day penal systems reflected the philosophy of reconciliation - abolishing the death penalty and placing greater faith in community relationships, alternative sentencing, and the rehabilitation of criminals. A person who served a sentence was seen as having paid the dues: in Poland and many other European countries, his or hers prospective employers would be barred from inquiring about the criminal record, and the right to privacy would keep the indictments and court records from public view.

It's hard to say if the European model worked better when it comes to combating villainy; in the UK, crime trends followed the US trajectory; in Sweden, they did the opposite. But the utilitarian aspect of the correctional system aside, the US approach certainly carries a heavy humanitarian toll: the country maintains a truly astronomical prison population, disproportionately comprised of ethnic minorities and the poor; recidivism rates are high and overcrowding borders on the inhumane. The continued incarceration of people sentenced for non-violent cannabis-related crimes flies in the face of changing social norms.

Untangling this mess is going to take time; most Americans seriously worry about crime and see it as a growing epidemic, even if their beliefs are not substantiated by government-published stats. Perhaps because of this, they favor tough policing; reports of potential prosecutorial oversight - such as the recent case of a tragic homicide in San Francisco - tend to provoke broader outrage than any comparable claims of overreach. Similarly, police brutality or prison rape are widely acknowledged and even joked about - but seen as something that only ever happens to the bad folks.

For the next article in the series, click here.

July 04, 2015

Poland vs the United States: the cutting edge of technology

This is the ninth article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

No matter what's your take on the United States, there is no denying that the country has been on the forefront of scientific and industrial progress for much of the past century. In that time frame alone, the nation's research institutions and corporations have made countless fundamental contributions to almost every single aspect of contemporary technology - from polymer science, to computing, to aviation, to medicine, to nuclear power, to space exploration, to communications, to modern warfare.

Given the country's track record of relentless innovation, one would expect its residents to be quick to embrace technological novelties and futuristic design trends. But when it comes to everyday living, I find that the opposite is often more true. Let's take banking: many of my Polish friends recoil in terror when they find out that the world's most sophisticated financial system still settles many private transactions by writing checks; that in stores, you usually swipe the magnetic strip and scribble your name on a piece of paper; or that sending a wire transfer usually involves a trip to your bank, a hefty fee, and waiting a couple of days.

For many of them, it must be equally perplexing to visit a typical well-off American home. Kitchens are a good example: in much of continental Europe, the standard of upscale kitchen architecture tends to revolve around sleek, sterile looks constructed out of flat panes of glass, steel, plastic, and concrete; the drawers and cabinets will cleverly blend in to reveal space-age appliances hidden inside. The kitchen is, in essence, the embodiment of technological progress and of modern design aesthetics.

In the US, the European school of design has gained some foothold in pricey downtown apartments targeted at the wealthy youth - but the dominant, all-American archetype looks nothing like it. Many of the newly-built houses will feature old-fashioned, bulky granite countertops and ornate but functionally basic colonial-style wooden carpentry; most of the fancy small appliances will feel like they were pulled straight out of the 30s, too. Decorative details, such as crown moldings, vaulted ceilings, and marble columns are thrown in to differentiate luxury developments from the housing available to the middle class. Elsewhere in the house, featureless top-loading washing machines and clunky upright vacuums are a common sight.

The contrast is interesting and difficult to explain; it's certainly not that Americans are Luddites: they are quick to take lead with many types of utilitarian technologies. The country pioneered and popularized everything from refrigerators, to air conditioning, to dishwashers, to automatic transmission, to smartphones, to microwaves. It's also not that the residents show special reverence to the traditions of the bygone days. Perhaps the utilitarian principle is key: it may be that consumers judge many of their purchases based the utility and lasting value of the durable goods, more than their novelty or the image said goods may project.

If so, the observation would fly in the face of the country's reputation for rampant consumerism, a stereotype frequently contrasted with the meditated sophistry of Europe. But then, the conclusion may be overly broad: even within the United States, there are many interesting differences in how tangible goods are used to signal personal wealth. In Los Angeles or Miami, just like in much of Europe, luxury sports vehicles are a widely accepted symbol of affluence. In Silicon Valley, the practice is frowned upon, with many of the dot-com millionaires living in unassuming homes and driving fuel-efficient cars. Perhaps this is a matter of social conscience; perhaps of having different priorities; and perhaps simply of fearing that they would be vilified by the society.

For the next article in the series, click here.

June 29, 2015

Poland vs the United States: suburban sprawl

This is the eighth article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

If you live in any other western country, your perception of the United States is bound to be profoundly influenced by Hollywood. You may think you're immune to it, but you are not: sure, you can sneer at the ridiculous plot holes or the gratuitous patriotism in American blockbusters - but the establishing shots of high-rise cityscapes of Manhattan or Los Angeles will be seared into your mind. These images will color your expectations and your understanding of the country in more ways than you may expect.

Because of this phenomenon, urban dwellers from Europe who come to visit the US may be in for a surprise: the country will probably feel a lot more rural than they would have thought. They will get to marvel the grand cities and the iconic skyscrapers; but chances are, this scenery will quickly morph not into the familiar urban jungle of massive apartment blocks seen throughout much of Europe, but into the endless suburban sprawl of single-family homes and strip malls.

For most Americans, this vast, low-density suburban landscape is the backdrop of their everyday lives. Take San Francisco: just 800,000 people live in the city proper. The San Francisco Bay Area, the home to 8 million residents and the location of the largest and most influential tech hub in the world, is nothing more than an enormous stretch of greenery peppered with detached homes, unassuming two-story office buildings, and roadside car dealerships. Heck, even New York City, by far the largest urban conglomeration in America, is just a blip on the radar compared to the colossal suburban sprawl that engulfs the region - stretching all the way from Massachusetts to Washington D.C.

The raw numbers paint a similar picture: in Poland, the average population density is around 125 people per square kilometer; in the more densely populated Germany, the figure is closer to 220. In comparison, with fewer than 35 people per km2, the United States comes out looking like a barren wasteland. The country has many expanses of untouched wilderness - and quite a few rural regions where the residents get by without as little as a postal address, a nearby fire station, a police department, or a hospital.

Awareness of the predominantly suburban and rural character of much of the US is vital to understanding some the national stereotypes that may seem bizarre or archaic to urban-dwelling Europeans. It certainly helps explain the limited availability of public transportation, or the residents' love for rifles and gas-guzzling pickup trucks. The survivalist "prepper" culture, focused on self-sufficiency in the face of disaster, is another cultural phenomenon that although seemingly odd, is not just pure lunacy; in the past few decades, millions of Americans had to evacuate or dig in in response to hurricanes, wildfires, earthquakes, or floods.

The stark difference between urban and rural living can also make it easier to grasp some of the ideological clashes between the big-city liberal progressives and the traditionally conservative dwellers of the so-called "flyover states". Sometimes, the conservatives are simply on the wrong side of history; but on some other occasions, the city-raised politicians, scholars, and journalists are too eager to paint the whole nation with the same brush. Take something as trivial as car efficiency standards: they will rub you one way if you take subway to the office and drive your compact car to the grocery store; and another if you ever needed to haul firewood or construction materials on the back of your Ford F-150.

For the next article in the series, click here.

June 28, 2015

Poland vs the United States: friends & acquaintances

This is the seventh article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

Cultural stereotypes are a dangerous and corrosive thing. They teach us that Poles are a tribe of thieving simpletons; or that Americans are arrogant, violent, and obese. And that's just the ethnicities that get off easy: the perception of blacks, Muslims, or European Jews can be far more vicious, often serving a pretext for violent hate crime.

At the same time, there is no denying that certain unique archetypes are etched into the fabric of every society. I'd also posit that when cultures come into contact with each other, there is an uncanny valley effect at play: the more similar the nations are, the easier it is for travelers to instinctively pick up the subtle variations - and to misread them as the personality quirks of the people they interact with.

For Poles who settle in the United States, the most striking contrast of this sort must be the persistence with which Americans want to engage in oddly personal small talk: you will be always greeted with "how are you?", be it by the cashier at a grocery store, by your mailman, by the park ranger met at a trail, or by the waiter serving your food at a restaurant. The social expectation is to share short pleasantries or announce a brief piece of good news. But if your answer is overly specific or focuses on a negative event, you may be given quizzical looks and the conversation will stall.

To many of my compatriots, the exchange - lacking any apparent purpose - feels uncomfortable and insincere. I try not to look at it in a cynical way: the upbeat chit-chat, repeated over and over again, can probably make your day a bit better and a tad more fun. This constrained form of communication also provides something to build on the next time you see that person, even if every individual interaction is necessarily non-committal and brief.

Another explanation for the forced positivity may have to do with the pervasive can-do spirit at the core of the American culture. The national ethos of self-determination and unconstrained social mobility flies in the face of the daily struggles of disadvantaged citizens - but it remains a fundamental part of the cultural identity of the United States. The American Dream manifests itself everywhere, from the country songs of the Midwest to the high-tech entrepreneurship of the Silicon Valley. Your friends, coworkers, neighbors, and even complete strangers are there to support you when true calamity strikes - but dwelling on everyday mishaps is almost universally seen as a weakness that one needs to overcome in order to succeed in life.

In this regard, the Polish culture is strikingly different. After hundreds of years of political repression and foreign control, Poles have developed a colorful tradition of sarcastic humor and idle lamentation. This coping mechanism functions to this day: to a Pole, being asked about your day is seen as an invitation to air all the petty grievances; you wouldn't expect a friend to smile, exclaim "I'm doing great!", and move on. Complaining about politics or work is how you build rapport with your peers. In fact, being overly upbeat or talking about professional success or accomplishment is likely to be met with suspicion or scorn. If you're a successful entrepreneur, you will probably open by complaining about your dealings with the Polish equivalent of the IRS.

In many ways, the Polish approach to chit-chat is more genuine and less rigid. At the same time, I feel that the negativity comes at a price; meeting a cranky clerk at a store sets the tone for the remainder of your day. The constant pessimism can also dampen some altruistic instincts: relatively few people in Poland get engaged in their communities or dedicate themselves to other forms of civic service. It is more accepted to just complain about the ways things are.

Interestingly, in the United States, the boundaries that govern the conversations with complete strangers also extend into the workplace. When interacting with casual acquaintances, sarcasm is seen as jarring, while petty grumbling is perceived as an off-putting and unproductive personality trait. Off-color humor, widely tolerated in Poland, is usually inappropriate in white collar environments; doubly so if it comes at the expense of women, immigrants, or other disadvantaged social groups.

Some Europeans characterize the workplace etiquette in the US as political correctness run amok. There are situations where political correctness can stifle free speech, but I don't think it's one of them; for most part, not hearing political rants or jokes about blondes or Jews just makes the world a bit better, even if the comments are uttered with no ill intent. Violating these rules will not necessarily get you in trouble, but in a culturally diverse society, it can make it harder to find new friends.

For the next article in the series, click here.

June 23, 2015

Poland vs the United States: civil liberties

This is the sixth article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

I opened my comparison of Poland and the US with the topic of firearm ownership. I decided to take this route in part because of how alien the US gun culture may appear to outsiders - and because of how polarizing and interesting the subject is. But in today's entry, I wanted to take a step back and have a look at the other, more traditional civil liberties that will be more familiar to folks on the other side of the pond.

Before we dive in, it is probably important to note that the national ethos of the United States is very expressly built on the tradition of individualism and free enterprise. Of course, many words can be written about the disconnect between this romanticized vision and complex realities of entrepreneurship or social mobility in the face of multi-generational poverty or failing inner-city schools (it may be a fitting subject for another post). But the perception still counts: in much of Europe, the government is seen less as a guarantor of civil liberties, and more as a provider of basic needs. The inverse is more true in the US; the armed forces and small businesses enjoy the two top spots in institutional trustworthiness surveys; federal legislators come dead last. This sentiment shapes many of the ongoing political debates - not just around individual freedoms, but also as related to public healthcare or the regulation of commerce. The virtues of self-sufficiency and laissez-faire capitalism seem far more self-evident to the citizens of the US than they are in the EU.

With that in mind, it's worthwhile to start the comparison with the freedom of speech. A cherished tradition in the western world, this liberty is nevertheless subordinate to a number of collectivist social engineering goals across the whole old continent; for example, strong prohibitions exist on the promotion of Nazi ideology or symbolism, or on the mere practice of denying the Holocaust. The freedom of speech is also broadly trumped by the right to privacy, including the hotly-debated right to be forgotten on the Internet. Other, more exotic restrictions implemented in several places in Europe include the prohibition against disrespecting the religious beliefs of others or insulting any acting head of state; in Poland, people have been prosecuted for hurling childish insults at the Pope or at the outgoing Polish president. Of course, the enforcement is patently selective: in today's political climate, no one will be charged for calling Mr. Putin a thug.

The US takes a more absolutist view of the First Amendment, with many hate groups enjoying far-reaching impunity enshrined in the judicial standards put forward not by politicians, but by the unusually powerful US Supreme Court. The notion of "speech" is also interpreted very broadly, extending to many forms of artistic, religious, and political expression; in particular, the European niqab and burka bans would be patently illegal in the United States and aren't even the subject of serious debate. The concept of homeschooling, banned or heavily regulated in some parts of Europe, is seen by some through the same constitutional prism: it is your right to teach your children about Young Earth creationism, and the right trumps any concerns over the purported social costs. Last but not least, there is the controversial Citizens United decision, holding that some forms of financial support provided to political causes can be equated with constitutionally protected speech; again, the ruling came not from the easily influenced politicians, but from the Supreme Court.

As an aside, despite the use of freedom-of-speech restrictions as a tool for rooting out anti-Semitism and hate speech in Europe, the contemporary US may be providing a less fertile ground for racism and xenophobia than at least some parts of the EU. The country still struggles with its dark past and the murky reality of racial discrimination - but despite the stereotypes, the incidence of at least some types of casual racism in today's America seems lower than in much of Europe. The pattern is also evident in political discourse; many of the openly xenophobic opinions or legislative proposals put forward by European populist politicians would face broad condemnation in the US. Some authors argue that the old continent is facing a profound new wave of Islamophobia and hatred toward Jews; in countries such as Greece and Hungary, more than 60% of population seems to be holding such views. In Poland, more than 40% say that Jews hold too much influence in business - a surreal claim, given that that there are just several thousand Jews living in the country of 38 million. My own memories from growing up in that country are that of schoolkids almost universally using "you Jew!" as a mortal insult. The defacement of Jewish graves and monuments, or anti-Semitic graffiti, posters, and sports chants are far more common than they should be. It's difficult to understand if restrictions on free speech suppress the sentiments or make them worse, but at the very least, the success of the policies is not clear-cut.

Other civil liberties revered in the United States, and perhaps less so in Europe, put limits on the ability of the government to intrude into private lives through unwarranted searches and seizures. Of course, the stereotypical view of the US is that of a dystopian surveillance state, epitomized by the recent focus on warrantless surveillance or secret FISA courts. But having worked for a telecommunications company in Poland, my own sentiment is that law enforcement and intelligence agencies in Europe tend to operate with far more impunity and far less legal oversight; the intelligence community in particular is often engaged in politically motivated domestic investigations that should raise an eyebrow or two; all across Europe, "pre-crime" policing ideas are taking hold. In most of these countries, citizens are not afforded powerful tools such as FOIA requests, do not benefit from a tradition of protected investigative journalism and whistleblowing, and can't work with influential organizations such as the American Civil Liberties Union; there is also no history of scandals nearly as dramatic and transformative as Watergate. In the States, I feel that all this helped to create an imperfect but precious balance between the needs of the government and the rights of the people - and instill higher ethical standards in the law enforcement and intelligence community. The individualist spirit helps, too: quite a few states and municipalities go as far as banning traffic enforcement cameras because of how they rob suspects of the ability to face the accuser in court.

When it comes to some other civil traditions that are sacrosanct in Europe, the United States needs to face justified criticism. The harsh and overcrowded penal system treats some offenders unfairly; it is a product of populist sentiments influenced by the crime waves of the twentieth century and fueled by the dysfunctional War on Drugs. While Polish prisons may not be much better, some of the ideas implemented elsewhere in Europe seem to make a clear difference. They are difficult to adopt in the States chiefly because they do not fit the folksy "tough on crime" image that many American politicians take pride in.

In the same vein, police brutality, disproportionately faced by the poor and the minorities, is another black mark for individual rights. The death penalty, albeit infrequent and reserved for most heinous crimes, stands on increasingly shaky moral grounds - even if it faces steady public support. The indefinite detention and torture of terrorism suspects, with the knowledge and complicity of many other European states, deserves nothing but scorn. Civil forfeiture is a bizarre concept that seems to violate the spirit of the Fourth Amendment by applying unreasonably relaxed standards for certain types of seizures - although in all likelihood, its days are coming to an end.

As usual, the picture is complex and it's hard to declare the superiority of any single approach to individual liberties. Europe and the United States have much in common, but also differ in very interesting ways.

For the next article in the series, click here.

June 22, 2015

A bit more on firearms in the US

This is the fifth article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

Perhaps not surprisingly, my previous blog post sparked several interesting discussions with my Polish friends who took a more decisive view of the social costs of firearm ownership, or who saw the Second Amendment as a barbaric construct with no place in today's world. Their opinions reminded me of my own attitude some ten years ago; in this brief follow-up, I wanted to share several data points that convinced me to take a more measured stance.

Let's start with the basics: most estimates place the number of guns in the United States at 300 million - that's roughly one firearm per every single resident. In Gallup polls, roughly 40-50% of all households report having a gun, frequently more than one. The demographics of firearm ownership are more uniform than stereotypes may imply; there is some variance across regions, political affiliations, and genders - but it tends to fall within fairly narrow bands.

An overwhelming majority of gun owners cite personal safety as the leading motive for purchasing a firearm; hunting and recreation activities come strong second. The defensive aspect of firearm ownership is of special note, because it can potentially provide an argument for protecting the right to bear arms even when it comes at an elevated cost to the society as a whole.

The self-defense argument is sometimes dismissed as pure fantasy - and it's only fair to ask for evidence that goes beyond the anecdotes about Katrina or other catastrophic events. There is no precise data about the frequency with which firearms are routinely used to deter threats; the results of scientific polls are open to interpretation and vary significantly depending on sampling methods and questions asked. That said, a recent meta-analysis from Centers for Disease Control and Prevention provided some general bounds:

"Defensive use of guns by crime victims is a common occurrence, although the exact number remains disputed (Cook and Ludwig, 1996; Kleck, 2001a). Almost all national survey estimates indicate that defensive gun uses by victims are at least as common as offensive uses by criminals, with estimates of annual uses ranging from about 500,000 to more than 3 million."

The study also goes on to say:

"A different issue is whether defensive uses of guns, however numerous or rare they may be, are effective in preventing injury to the gun-wielding crime victim. Studies that directly assessed the effect of actual defensive uses of guns (i.e., incidents in which a gun was “used” by the crime victim in the sense of attacking or threatening an offender) have found consistently lower injury rates among gun-using crime victims compared with victims who used other self-protective strategies."

An argument can be made that the availability of firearms translates to higher rates of violent crime, thus elevating the likelihood of encounters where a defensive firearm would be useful. That said, such an effect does not seem to be particularly evident. For example, the United States comes out favorably in statistics related to assault, rape, and robbery - that is, compared to other OECD countries with far lower firearm ownership rates.

The area where the United States clearly falls behind other developed countries are homicides; the per-capita figures are almost three times as high as in much of the European Union. And indeed, the bulk of intentional homicides - some 11 thousand deaths a year - trace back to firearms.

That said, the origins of this tragic situation may be more elusive than they at first appear. For one, non-gun-related homicides happen in the US at a higher rate than in many other countries, too. In addition, no clear pattern emerges when comparing homicide rates across states with permissive and restrictive gun ownership laws. Some of the lowest per-capita homicide figures can be found in extremely gun-friendly states such as Idaho, Utah, or Vermont; whereas highly-regulated Washington D.C., Maryland, Illinois, and California all rank pretty high. It is likely that factors such as population density, urban poverty, and drug-related gang activities play a far more significant role, compared to the ease with which law-abiding people may purchase or bear arms.

International comparisons show a more clear correlation between gun ownership and crime, but it's difficult to draw solid conclusions from that: there are many other excellent reasons why crime rates may be low in the wealthy European states, and high in the impoverished regions in Africa or the Middle East. When comparing European countries alone, the picture is far from being clear-cut: gun ownership in Poland is almost twenty times lower than in neighboring Germany and ten times lower than in Czech Republic - but you wouldn't able to tell that from the crime stats.

When it comes to legislative approaches, one CDC study on the topic concluded with:

"The Task Force found insufficient evidence to determine the effectiveness of any of the firearms laws or combinations of laws reviewed on violent outcomes."

This does not imply that such approaches are necessarily ineffective; for example, it seems pretty reasonable to assume that background checks or waiting periods do save lives. Similarly, safe storage requirements would likely prevent dozens of child deaths, although they would probably make firearms less useful for self-defense. But for the hundreds of sometimes far-fetched gun control proposals introduced every year on federal and state level, emotions often take place of real data, poisoning the debate around gun laws and ultimately bringing little or no public benefit. The heated assault weapon debate is one such red herring: although semi-automatic rifles look sinister, they are far more common in the movies than on the streets, and in reality account only for somewhere around 4% of all firearm homicides.

Another oddball example of legislative zeal are the attempts to mandate costly gun owner liability insurance, based on drawing an impassioned but flawed parallel between firearms and cars; what undermines this argument is that car accidents are commonplace, while gun handling mishaps - especially ones that injure others - are rare. There are also proposals to institute $100 ammunition purchase permits or to prohibit ammo sales over the Internet. Many critics feel that such laws seem to be geared not toward addressing any specific dangers, but toward making firearms more expensive and burdensome to own - slowly eroding the constitutional rights of the less wealthy folks. They also see hypocrisy in the common practice of making retired police officers and many high-ranking government officials exempt from said laws.

Regardless of individual merit of the regulations, it's certainly true that with countless pieces of sometimes obtuse and poorly-written federal, state, and municipal statutes introduced every year, it's increasingly easy for people to unintentionally run afoul of the rules. In California, the law as written today implies that any legal permanent resident in good standing can own a gun, but that only US citizens can transport it by car. Given that Californians are also generally barred from carrying firearms on foot in many populated areas, non-citizen residents are seemingly expected to teleport between the gun store, their home, and the shooting range. With many laws hastily drafted in the days after mass shootings and other tragedies, such gems are commonplace. The federal Gun-Free School Zones Act imposes special restrictions on gun ownership within 1,000 feet of a school and slaps harsh penalties for as little carrying it in an unlocked container from one's home to a car parked in the driveway. In many urban areas, a lot of people either live within such a school zone or can't conceivably avoid it when going about their business; GFSZA violations are almost certainly common and are policed only selectively.

Meanwhile, with sharp declines in crime continuing for the past 20 years, the public opinion is increasingly in favor of broad, reasonably policed gun ownership; for example, more than 70% respondents to one Gallup poll are against the restrictive handgun bans of the sort attempted in Chicago, San Francisco, or Washington D.C.; and in a recent Rasmussen poll, only 22% say that they would feel safer in a neighborhood where people are not allowed to keep guns. In fact, worried about the historically very anti-gun views of the sitting president, Americans are buying a lot more firearms than ever before. Even the National Rifle Association - a staunchly conservative organization vilified by gun control advocates and mainstream pundits - enjoys a pretty reasonable approval rating across many demographics: 54% overall and 71% in households with a gun.

And here's the kicker: despite its reputation for being a political arm of firearm manufacturers, the NRA is funded largely through individual memberships, small-scale donations, and purchase round-ups; organizational donations add up to about 5% of their budget - and if you throw in advertising income, the total still stays under 15%. That makes it quite unlike most of the other large-scale lobbying groups that politicians aren't as likely to name-and-shame on the campaign trail. The NRA's financial muscle is also frequently overstated; gun control advocacy groups, backed by activist billionaires such as Michael Bloomberg, now frequently outspend the pro-gun crowd. The association's socially conservative and unnecessarily polarizing rhetoric needs to be offset by the voice of other, more progressive civil liberties groups; but ironically, organizations such as American Civil Liberties Union - well-known for fearlessly defending controversial speech - prefer to avoid the Second Amendment because it doesn't sit well with their own, progressive support base.

America's attitude toward guns is a choice, not a necessity. It is also true that gun violence is a devastating problem; its emotional horror and lasting social impact can't be possibly captured in any cold, dry statistic alone. But there is also nuance and reason to the gun control debate that can be hard to see for newcomers from more firearm-averse parts of the world.

For the next article in the series, click here.

June 14, 2015

Poland vs the United States: firearms

This is the fourth article in a short series about Poland, Europe, and the United States. To explore the entire series, click here.

I spent roughly half of my adult life in Poland; for the other half, we lived in the United States. Because of this, my Polish friends sometimes ask about the cultural differences between the two countries. I always struggle to answer on the spot, so I decided to explore some of the most striking dissimilarities in a series of short blog posts. It's only fitting to start with guns.

Although you won't hear this being brought up by any gun control advocate, Poland has long had one of the strictest firearms laws in the world, far ahead of most other countries in Europe. The roots of this policy are difficult to pinpoint, but it may have had to do with the years of foreign partitions, followed by the Soviet-imposed communist rule; in those trying times, private militias must have been seen as a grave threat to the social order and to the personal safety of the ruling class. Whatever the original reasoning, the effects are plain to see: in today's Poland, there is almost no tradition of gun ownership or hobby shooting sports; the country averages just around one firearm per 100 residents, compared to almost seven in the UK, sixteen in the Czech Republic, or thirty in Germany. It's likely that most Poles do not even know anyone who legally owns a gun.

In many ways, the United States may seem like the polar opposite: we have enough privately-owned firearms to equip almost every single man, woman, and child. In much of the country, there is no permitting process for new purchases and no registration requirements for handguns, rifles, or shotguns. The weapons can be bought at trade shows, given to family members, or loaned to friends. If you want to own an AR-15 just because it looks like fun, you can have it - and many people get it for that reason alone.

In America, the right to bear arms is an ancient tradition going all the way back to the early days of the republic, envisioned as a constitutional safeguard to resist feudal subjugation and to guarantee the sovereignty of the fledgling country - at a time when its citizens still expected the British to come back and claim what's theirs. In the minds of some, the Second Amendment is still the only thing that stands between freedom and tyranny; but for many others, gun ownership is simply an empowering family hobby pursued at any of the tens of thousands shooting ranges all across the United States. In a country populated far less densely than Europe, there is also some utilitarian aspect to it all: especially for rural populations, rifles are seen as a necessity for defending properties against wild animals or scaring away criminals or drunken thugs.

Of course, all this comes at a price: the US leads the developed world in gun suicides and homicides. The causes of this phenomenon are complex and deeply intertwined with the American psyche; although there are many intuitive explanations and although countless comparisons to be made to European countries, most of that does not hold up to closer scrutiny. Still, it would be dishonest to claim that easy access to firearms takes no toll; some of the most vivid pictures seared into people's minds are the infrequent but soul-crushing school shootings. A more everyday occurrence are police encounters that end tragically because of the presumption that any suspects - even children - may be armed to their teeth.

Over the last century, the looming specter of gun violence has led to increasing federal and state regulation of firearms. It is probable that some of these rules save lives with little harm to civil liberties; examples of this may include restrictions on fully-automatic weapons or the requirement for background checks. But other policies tried to reshape the society in far more heavy-handed ways; for example, Chicago Washington D.C., and San Francisco both attempted to impose blanket bans on handgun ownership. In New Orleans, the officials went as far as going door to door and forcibly confiscating firearms in the wake of hurricane Katrina; their hearts were probably in the right place - but the legal basis for this or the wisdom of doing so in a ravaged city seemed dubious at best.

In recent years, such zealous approaches inevitably meet their end in the courtroom - judges, much to gun control advocates' chagrin, see the awkwardly-worded Second Amendment as a proclamation of a very clear, individual right. If anything, the zeal of anti-gun activists has made it harder to have a reasonable discussion about the limits of gun rights: the constant onslaught of half-baked legislation creates a toxic atmosphere where many firearms enthusiasts and interest groups feel that their freedom is under assault - and that the only way to avoid gradual erosion of constitutional rights is to fight each and every new proposal tooth and nail. One of the sticking points for the National Rifle Association is that federal gun registries would make it easy for the "baddies" to confiscate all firearms in the country. To many, this seemingly preposterous idea rings a lot less hollow after the New Orleans incident.

In Europe, and in Poland in particular, gun laws in the US are often seen as a deranged product of a powerful gun lobby that works against the will and to the detriment of normal citizens; some progressive politicians, scholars, and pundits in the US adopt the same view. But when buying into this narrative, it is easy to overlook that the lobby in question is funded chiefly not by large corporations or the super-rich, but by ordinary citizens - and that it enjoys steady popular support.

In my younger years, I remember being entranced by "Bowling for Columbine", viscerally hating the National Rifle Association, and shaking my head in disbelief at the stereotype of gun-totting, trigger-happy Americans. Today, I see the reality as far more nuanced - and despite never having fired a gun in my life, if forced to take sides in this fascinating and emotional clash between collectivism and civil rights, I'm less sure that collectivism would always get my vote.

The article continues; for the second part, click here.

June 11, 2015

New in AFL: persistent mode

Although American Fuzzy Lop comes with a couple of nifty performance optimizations, it still relies on a fairly resource-intensive routine that is common to most general-purpose fuzzers: it continually creates new processes, feeds them a single test case, and then discards them to start over from scratch.

To avoid the overhead of the notoriously slow execve() syscall and the linking process, the fuzzer automatically leverages the forkserver optimization, where new processes are cloned from a copy-on-write master perpetually kept in a virgin state. This allows many targets to be fuzzed faster than with other, conventional tools. But even with this hack, each new input still incurs the cost of fork(). On all supported OSes with the exception of MacOS X, the fork() call is actually surprisingly fast - but certainly does not come free.

For some common fuzzing targets, such as zlib or libpng, the constant cycle of forking and initialization is a significant and avoidable bottleneck. In many cases, the underlying APIs are either stateless, or can be reliably reset to a nearly-pristine state across inputs - so at least in principle, you don't have to throw away the child process after every single run. That's where in-process fuzzing tends to shine: in this scheme, the test cases are generated inline and fed to the underlying API in a custom-written, single-process loop. The speed gains offered by in-process fuzzing can be as high as 10x, but the approach comes at a price; for example, it is easily derailed by accidental memory leaks or DoS conditions in the tested code.

Well, the good news is that starting with version 1.81b, afl-fuzz supports an optional "persistent" mode that combines the benefits of in-process fuzzing with the robustness of a more traditional multi-process tool. In this scheme, the fuzzer feeds test cases to a separate, long-lived process that reads the input data, passes it to the instrumented API, notifies the parent about successful run by stopping its own execution; eventually, when resumed by the parent, the process simply loops back to the start. You need to write a minimalist harness to implement the loop, but AFL takes care of most of the remaining tricky stuff, including crash handling, stall detection, and the usual instrumentation magic that AFL is designed for:

int main(int argc, char** argv) {


  /* Reset state. */
  memset(buf, 0, 100);

  /* Read input data. */
  read(0, buf, 100);

  /* Parse it in some vulnerable way. You'd normally call a library here. */
  if (buf[0] != 'p') puts("error 1"); else
  if (buf[1] != 'w') puts("error 2"); else
  if (buf[2] != 'n') puts("error 3"); else

  /* Tell the parent that we're done. When resumed, loop back. */
  goto try_again;


For a more complete example, see experimental/persistent_demo/ and be sure to read the last section of llvm_mode/README.llvm. This feature is inspired by the work done by Kostya Serebryany on LibFuzzer (which is, in turn, inspired by AFL); additional credit goes to Christian Holler, who started a conversation that finally prompted me to integrate this mode with the tool.

May 20, 2015

Lesser-known features of afl-fuzz

AFL is designed to be simple to use, but there are quite a few advanced, time-saving features that may be easy to overlook. So, here are several useful tricks that aren't covered in README:

  • Test case postprocessing: need to fix up checksums or length fields in a particular file format? AFL supports modular postprocessors that can take care of this for you. See experimental/post_library/ for sample code and other tips.

  • Deferred forkserver: stuck with a binary that initializes a lot of stuff before actually getting to the input data? When using clang, you can avoid this CPU overhead by instructing AFL to clone the process from an already-initialized image. It's simpler than it sounds - have a look at llvm_mode/README.llvm for advice.

  • Helpful stats: in addition to using afl-plot to generate pretty progress graphs, you can also directly parse <out_dir>/fuzzer_stats for machine-readable statistics on any background tasks. The afl-whatsup script is a simple demo of that.

  • Faster resume: if you don't care about detecting non-deterministic behavior in tested binaries, set AFL_NO_VAR_CHECK=1 before resuming afl-fuzz jobs. It can speed things up by a factor of ten. While you're at it, be sure to see docs/perf_tips.txt for other performance tips.

  • Heterogeneous parallelization: the parallelization mechanism described in docs/parallel_fuzzing.txt can be very easily used to co-fuzz several different parsers using a shared corpus, or to seamlessly couple afl-fuzz to any other guided tools - say, symbolic execution frameworks.

  • Third-party tools: have a look at docs/sister_projects.txt for a collection of third-party tools that help you manage multiple instances of AFL, simplify crash triage, allow you to fuzz network servers or clients, and add support for languages such as Python or Go.

  • Minimizing stuff: when you have a crashing test case, afl-tmin will work even with non-instrumented binaries - so you can use it to shrink and simplify almost anything, even if it has nothing to do with AFL.


May 17, 2015

Oh, the places you won't go: Polonia in the United States

This is the third article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

Naming the largest diasporas in the United States may seem like an easy task. For one, we have the deeply-assimilated families of German, Irish, Italian, and British immigrants. There is also a large Mexican community, unique for having a much higher percentage of members who were foreign-born.

Most people would venture a guess that India or China should come next; some may also suggest France, Denmark, or the Netherlands. They would be all wrong: the next spot on the list belongs to the massive Polish diaspora, estimated to be almost ten million strong.

Given its sheer size, the cultural influences of the Polish-American community are uncharacteristically subdued. There are precious few Poland-originating holiday traditions or ethnic foods. Outside a couple rapidly shrinking enclaves such as Avondale in Chicago or Greenpoint in New York City, you are unlikely to bump into posh Polish diners, pricey grocery stores, or flamboyant street parades. Children born to Polish immigrants in the US are seldom taught to read or write in their parents' language - and will probably know very little about their familial lineage or common ancestry.

Perhaps there just aren't that many bits of Polish culture to build on against the backdrop of Germanic, British, Italian, and Dutch influences that shaped the American life. Much like its German counterpart, the traditional Polish cuisine is obsessed chiefly with potatoes and meat. Today, we take pride in our pączki, but when pressed, we will sooner or later confess that they are just doughnuts by some other name. We can offer you some pierogi, but they will truly impress you only if you never had any ravioli or tortellini. We can also hook you up with some sausage, sauerkraut, pickles, ribs, or beer. On your way out, take a bite of our cheesecake or apple pie.

The holiday traditions run into the same challenge, perhaps with the exception of the infamous but niche Dyngus Day. Other than that, the most commonly observed practice is that in line with much of Central Europe, Polish children may get their gifts in the evening on Christmas Eve, not in the morning on Christmas Day. Our traditional clothing looks distinctive - but it is ornate and archaic, making it compare unfavorably with the beautiful simplicity of wearing green on St. Patrick's Day, or getting hammered in suspenders come Oktoberfest.

Humor aside, a more powerful clue to the invisibility of the Polish diaspora may lie in its very history. In the twentieth century, the immigrants from Poland ended up occupying three isolated social strata, with relatively few opportunities for working together and developing any form of a shared cultural identity.

The first and most populous stratum of contemporary immigration were the common folk, displaced by the horrors of the war and the crippling poverty that followed under communist rule. Many of them worked menial jobs, spoke little or no English, and clustered around many of the traditionally Polish enclaves that offered them a degree of familiarity and support. For many years, they and their children faced blatant discrimination, epitomized by the popular "Polish jokes" in the 1960s and 1970s. The demeaning stereotypes that followed them everywhere prompted many Poles to adopt Americanized names, intermarry, and keep their origins a private affair.

The second stratum were the dissidents and the disillusioned intellectuals leaving Poland to escape the dysfunctional regime. Usually better-educated and more confident, they helped build the first proper Polish-American institutions, including local newspapers, community organizations, churches, shipping and travel companies, or banks. The members of this group felt much stronger national identity and perceived themselves as the guarantors of Polish interests abroad. With the fall of communism in Europe, many of them were incredulous that the former dignitaries were allowed to walk free and play a role in business and politics - a sentiment that still shapes their political views.

The big change in immigration trends came with the accession of Poland to the European Union. The unhappy and the disenfranchised would now overwhelmingly favor moving to Germany or to the UK, where they could take up residence without having to deal with restrictive immigration laws. The remaining US-bound migration shifted toward skilled, university-trained engineers and IT workers, many of whom gravitated toward tech hubs such as SF Bay Area, Seattle, or NYC. Having been born in the 1970s and 1980s, most of them remembered Poland as a thriving capitalist democracy; they were driven not by despair, but by the prospects of better pay or more interesting work.

All this nuance is easily lost on the people back home. Many of the left-wing and centrist pundits in Poland demonize the expats in hopes of mobilizing the more moderate domestic electorate. They paint a picture of a frighteningly powerful voting block that will prop up any fringe, conservative candidate, as long as they promise to rid Polish politics of the Soviet sleeper agents and other increasingly fictitious communist legacy.

Of course, for most part, such reputation is bunk; although a good percentage of Polish-Americans are very distrustful of left-leaning politicians in their country of origin, only a tiny percentage of them ever turns up to actually cast a ballot, and their overall influence on the results of Polish elections is slim. Contrary to how they are perceived, they also do not blindly cling on to social conservatism; in American elections, they usually vote for Democrats.

That said, repeated over and over again, the catchy narrative about dimwitted compatriots can take a life of its own. Several weeks ago, Longin Pastusiak, an eminent Polish publicist and polician, penned a piece characterizing Polish-Americans as simpletons who only have a very shallow appreciation for the Polish heritage and who meekly submit to the supposedly powerful influences of the Roman Catholic church. He is not alone in his views; many go even further and call for the diaspora's voting rights to be taken away.

Having overcome discrimination in the States only to face bureaucratic hurdles and prejudiced, vitriolic nonsense back home, it's no wonder that most of the Polish immigrants just want to blend in and move on. In the long haul, it's probably a big loss - not necessarily for them, but for their former home.

Crowds at Polish Days in San Francisco (2010)

For the next article in the series, click here.

May 13, 2015

Oh, the places you won't go: The politics of Poland

This is the second article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.

Growing up in Poland in the 90s, I never cared much for politics. Back then, you wouldn't want to get overly attached to any political movement anyway: when a country of 38 million emerges from half a century of communist rule, you know there will be some kinks to iron out.

Sitting on the sidelines, I saw the views of others solidified by what seemed like happenstance. My mother, a promising white-collar worker cast aside by the new reality, leaned sharply to the left; she would sometimes wax lyrical about the good old days of socialism. My wife's father, a one-time Party member turned opposition activist, found himself playing a role for the increasingly polarizing right. My aunt, a mild-mannered professor of ethics, rose to prominence in the liberal Warsaw elites - and became one of the most outspoken voices of feminism and anticlericalism in the country. She had an uneasy but fruitful relationship with the centrist movement.

At the turn of the twentieth century, no matter which side you took, keeping up with the political landscape must have been a full-time job. The bitterly divided communist-era dissident circles splintered into dozens of ephemeral movements, with many familiar faces gravitating toward two camps: the economically liberal centrist party that flirted with the teachings of Margaret Thatcher; and the Christian nationalist movement that somewhat confusingly co-opted the notions of social solidarity with the underprivileged, then served that dish with a side of social conservatism and a hint of distrust toward the EU.

On the other side of the political spectrum, many of the former Party dignitaries joined forces and reinvented themselves as modern-day, pro-European social democrats. Despite the branding, the post-communist camp adopted a set of conservative economic policies seldom distinguishable from the direction taken by the centrist bloc. They brandished secular, progressive social attitudes - but in a deeply-religious country where catechesis has a largely uncontested place in public schools, they never dared to experiment with them to any real extent.

In many ways, I found it easier to pinpoint what these political movements had in common, not what set them apart. Their old-school leaders, by and large raised and educated in the communist era, had little experience with good governance or true statesmanship. Looking back at it, I think that the dissident camp was driven to some extent by an innate sense of entitlement to the spoils of overthrowing the communist rule. Their years at the helm were punctuated by unsportsmanlike cronyism, by shady deals around the sale of state-owned enterprises, and by attempts to cling on to power by entering absurd and ultimately self-destructive alliances with populist agrarian or nationalist movements.

The former communists played a different card. They saw themselves as the qualified, level-headed alternative to the argumentative and erratic right. They nurtured an image of proven leaders, even if their experience amounted to running a dysfunctional Soviet satellite state into the ground and then skillfully changing their views. For many years, they fared well in elections, but eventually, the mainstream left ended with a bang: the boldest of the many political scandals in the 2000s - afera Rywina - exposed an attempt to extort $5M from a newspaper publisher in exchange for striking down an antitrust provision in the proposed Polish media law.

Many stable democracies can afford a period of government dysfunction. For a time, this was certainly true for Poland: every modern-day democratic government to date had enough common sense to keep pushing for the integration with NATO and the European Union, worked to strike down or at least superficially modernize many of the communist-era laws, and never refused a penny of foreign aid. The unstoppable influx of capital did the rest, ushering a period of unprecedented stability and growth. The cracks would show only when you interacted with the state bureaucracy: with many levels of government permeated by centrally-appointed and disinterested ruling-party loyalists, getting a pothole fixed or a stop sign installed could very well prove to be an insurmountable task.

In some ways, that period of insensitivity to bad governance may be coming to an end. Driven away by a decade of stagnant wages coupled with the rapidly growing costs of living, some 2-3 million mostly young Poles decided to leave the country and seek a better life in the UK, in Germany, and in other parts of the EU. This, combined with sub-replacement fertility rates, must have put tremendous strain on the already-inadequate social security system - a safety net where the net retirement benefits hover somewhere around $400 a month.

In the most recent presidential elections in Poland, the centrist incumbent, Bronisław Komorowski, was so sure of his victory that he shunned televised debate. The voters not only turned up in droves to give his conservative opponent a healthy lead, but some 20% of them opted for a fringe anti-establishment candidate - a former punk rock singer with a knack for catchy lyrics but no experience in politics. The future is unknowable, but in the runoff elections, the punk rock aficionados are unlikely to vote for status quo.

Many of the moral authorities in Poland share the same dissident roots with the current president and are sympathetic to Mr. Komorowski's plight. One professor of political sciences prayed for the "radicalized youth" to leave the country, apparently unaware of how radical and divisive his own words may sound. The incumbent president was quick to note that he always supported the few scattered policy proposals that can be attributed to the anti-establishment candidate. He went on to meet with the voters and rebuked a young person asking how to get by on $550 a month. The president's answer: get a loan or find a better job.

For the next article in the series, click here.

April 14, 2015

Finding bugs in SQLite, the easy way

SQLite is probably the most popular embedded database in use today; it is also known for being exceptionally well-tested and robust. In contrast to traditional SQL solutions, it does not rely on the usual network-based client-server architecture and does not employ a complex ACL model; this simplicity makes it comparatively safe.

At the same time, because of its versatility, SQLite sometimes finds use as the mechanism behind SQL-style query APIs that are exposed between privileged execution contexts and less-trusted code. For an example, look no further than the WebDB / WebSQL mechanism available in some browsers; in this setting, any vulnerabilities in the SQLite parser can open up the platform to attacks.

With this in mind, I decided to take SQLite for a spin with - you guessed it - afl-fuzz. As discussed some time ago, languages such as SQL tend to be difficult to stress-test in a fully automated manner: without an intricate model of the underlying grammar, random mutations are unlikely to generate anything but trivially broken statements. That said, afl-fuzz can usually leverage the injected instrumentation to sort out the grammar on its own. All I needed to get it started is a basic dictionary; for that, I took about 5 minutes to extract a list of reserved keywords from the SQLite docs (now included with the fuzzer as testcases/_extras/sql/). Next, I seeded the fuzzer with a single test case:

create table t1(one smallint);
insert into t1 values(1);
select * from t1;

This approach netted a decent number of interesting finds, some of which were mentioned in an earlier blog post that first introduced the dictionary feature. But when looking at the upstream fixes for the initial batch, I had a sudden moment of clarity and recalled that the developers of SQLite maintained a remarkably well-structured and comprehensive suite of hand-written test cases in their repository.

I figured that this body of working SQL statements may be a much better foundation for the fuzzer to build on, compared to my naive query - so I grepped the test cases out, split them into files, culled the resulting corpus with afl-cmin, and trimmed the inputs with afl-tmin. After a short while, I had around 550 files, averaging around 220 bytes each. I used them as a starting point for another run of afl-fuzz.

This configuration very quickly yielded a fair number of additional, unique fault conditions, ranging from NULL pointer dereferences, to memory fenceposts visible only under ASAN or Valgrind, to pretty straightforward uses of uninitialized pointers (link), bogus calls to free() (link), heap buffer overflows (link), and even stack-based ones (link). The resulting collection of 22 crashing test cases is included with the fuzzer in docs/vuln_samples/sqlite_*. They include some fairly ornate minimized inputs, say:

INSERT INTO t0(docid,x)VALUES(-1E0,'0(o');
SELECT docid FROM t0 WHERE t0 MATCH'"0*o"';

All in all, it's a pretty good return on investment for about 30 minutes of actual work - especially for a piece of software functionally tested and previously fuzzed to such a significant extent.

PS. I was truly impressed with Richard Hipp fixing each and every of these cases within a couple of hours of sending in a report. The fixes have been incorporated in version 3.8.9 of SQLite and have been public for a while, but there was no upstream advisory; depending on your use case, you may want to update soon.